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
432d1c02
Commit
432d1c02
authored
Oct 05, 2007
by
Pietro Abate
Browse files
[r2005-06-02 11:52:35 by afrisch] Field access for XML attibutes
Original author: afrisch Date: 2005-06-02 11:52:35+00:00
parent
6a5dea60
Changes
4
Hide whitespace changes
Inline
Side-by-side
CHANGES
View file @
432d1c02
0.3.2
+2
Since
0.3.2
* Added split_atom, make_atom. Removed atom_of.
0.3.2+1
* Added char_of_int built_in function.
* Now int_of also accepts octal binary and hexadecimals
* Now int_of also accepts octal binary and hexadecimals
.
* The field access also works for XML element attributes.
0.3.2
* Bug fix in configure
...
...
runtime/eval.ml
View file @
432d1c02
...
...
@@ -302,7 +302,9 @@ and eval_xtrans_aux env brs acc = function
|
_
->
acc
and
eval_dot
l
=
function
|
Value
.
Record
r
->
LabelMap
.
assoc
l
r
|
Value
.
Record
r
|
Value
.
Xml
(
_
,
Value
.
Record
r
,_
)
|
Value
.
XmlNs
(
_
,
Value
.
Record
r
,_,_
)
->
LabelMap
.
assoc
l
r
|
v
->
Value
.
print
Format
.
std_formatter
v
;
failwith
(
"Cannot find field "
^
(
Label
.
to_string
(
LabelPool
.
value
l
)))
...
...
typing/typer.ml
View file @
432d1c02
...
...
@@ -874,12 +874,20 @@ and type_check' loc env e constr precise = match e with
type_check_string
loc
env
0
s
i
j
e
constr
precise
|
Dot
(
e
,
l
)
->
let
t
=
type_check
env
e
Types
.
Record
.
any
true
in
let
t
=
try
Types
.
Record
.
project
t
l
with
Not_found
->
raise_loc
loc
(
WrongLabel
(
t
,
l
))
in
verify
loc
t
constr
let
expect_rec
=
Types
.
record
l
(
Types
.
cons
constr
)
in
let
expect_elt
=
Types
.
xml
Types
.
any_node
(
Types
.
cons
(
Types
.
times
(
Types
.
cons
expect_rec
)
Types
.
any_node
))
in
let
t
=
type_check
env
e
(
Types
.
cup
expect_rec
expect_elt
)
precise
in
let
t_elt
=
let
t
=
Types
.
Product
.
pi2
(
Types
.
Product
.
get
~
kind
:
`XML
t
)
in
let
t
=
Types
.
Product
.
pi1
(
Types
.
Product
.
get
t
)
in
t
in
if
not
precise
then
constr
else
(
try
Types
.
Record
.
project
(
Types
.
cup
t
t_elt
)
l
with
Not_found
->
assert
false
)
|
RemoveField
(
e
,
l
)
->
let
t
=
type_check
env
e
Types
.
Record
.
any
true
in
...
...
web/manual/expressions.xml
View file @
432d1c02
...
...
@@ -550,6 +550,27 @@ evaluates to
]]>
</code>
.
</p>
<p>
There is another form of projection to extract attributes:
</p>
<sample>
<![CDATA[
%%e%%/@%%l%%
]]>
</sample>
<p>
which is equivalent to:
</p>
<sample>
<![CDATA[
transform %%e%% with <_ l=l>
_ -> l
]]>
</sample>
<p>
The dot notation can also be used to extract the value of the
attribute for one XML element:
</p>
<sample>
<![CDATA[
# <a x=3>
[].x;;
- : 3 = 3
]]>
</sample>
</section>
<section
title=
"Iteration over XML trees"
>
...
...
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