Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cduce
cduce
Commits
636c4755
Commit
636c4755
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2003-06-30 14:29:07 by cvscast] Empty log message
Original author: cvscast Date: 2003-06-30 14:29:07+00:00
parent
c1733997
Changes
1
Hide whitespace changes
Inline
Side-by-side
web/examples/xtransform.cd
View file @
636c4755
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
simplified definition of Xhtml
simplified definition of Xhtml
*)
*)
type Flow = Char | Block | Inline ;;
type Flow = Char | Block | Inline ;;
type Block = P | Heading | Lists | Blocktext | Char
type Block = P | Heading | Lists | Blocktext | Char
type Lists = Ul
type Lists = Ul
...
@@ -34,6 +32,7 @@ type B = <b>[ Inline* ];;
...
@@ -34,6 +32,7 @@ type B = <b>[ Inline* ];;
type Big =
<big>
[ Inline* ];;
type Big =
<big>
[ Inline* ];;
type Small =
<small>
[ Inline* ];;
type Small =
<small>
[ Inline* ];;
(* xtransform matches the patterns against the root element of each
(* xtransform matches the patterns against the root element of each
XML tree and, if it fails, it recursively applies itself to the
XML tree and, if it fails, it recursively applies itself to the
sequence of sons of the root.
sequence of sons of the root.
...
@@ -42,11 +41,9 @@ type Small = <small>[ Inline* ];;
...
@@ -42,11 +41,9 @@ type Small = <small>[ Inline* ];;
document as follows
document as follows
*)
*)
let bold(x:[Xhtml]):[Xhtml]=xtransform x with
<a
(
y
)
>
t -> [
<a
(
y
)
>
[
<b>
t] ]
let bold(x:[Xhtml]):[Xhtml]=xtransform x with
<a
(
y
)
>
t -> [
<a
(
y
)
>
[
<b>
t] ]
(* let us apply the function to a document where links appear
(* let us apply the function to a document where links appear
at different depths
at different depths
*)
*)
...
@@ -57,7 +54,7 @@ let doc : Xhtml =
...
@@ -57,7 +54,7 @@ let doc : Xhtml =
<head>
[
<title>
"Example"
<link>
[]]
<head>
[
<title>
"Example"
<link>
[]]
<body>
[
<body>
[
<h2>
['You can have links '
<a
href=
"here"
>
"here"]
<h2>
['You can have links '
<a
href=
"here"
>
"here"]
<p>
['Or they can be down']
<p
re
>
['Or they can be down']
<ul>
[
<ul>
[
<li>
['In '
<a
name=
"list"
>
"lists" ' for instance']
<li>
['In '
<a
name=
"list"
>
"lists" ' for instance']
<li>
['or you oddly decided to '
<li>
['or you oddly decided to '
...
@@ -65,15 +62,19 @@ let doc : Xhtml =
...
@@ -65,15 +62,19 @@ let doc : Xhtml =
' them '
' them '
]
]
]
]
<address>
[
<address>
[
'and even if they are in fancy '
<a
name=
"address"
>
"address boxes"
'and even if they are in fancy '
<a
name=
"address"
>
"address boxes"
]
<p>
[
'nevertheless '
<a
href=
"http://www.cduce.org"
>
"Cduce" ' and '
<a
href=
"xtransform"
>
[
<tt>
"xtransform"]
' will put all links in bold so that when'
' you program your transformation you '
<big>
[
<a
name=
""
>
" don\'t " ] ' have to worry about it'
]
]
<p>
['nevertheless '
<a
href=
"http://www.cduce.org"
>
"Cduce" ' and '
]
<a
href=
"xtransform"
>
[
<tt>
"xtransform"] ' will put all links in bold ']
]
];;
];;
bold [doc];;
bold [doc];;
match
let [x] = bold [doc] in print_xml x;;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment