Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
66
Task/XML-XPath/Bracmat/xml-xpath.bracmat
Normal file
66
Task/XML-XPath/Bracmat/xml-xpath.bracmat
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
{Retrieve the first "item" element}
|
||||
( nestML$(get$("doc.xml",X,ML))
|
||||
: ?
|
||||
( inventory
|
||||
. ?,? (section.?,? ((item.?):?item) ?) ?
|
||||
)
|
||||
?
|
||||
& out$(toML$!item)
|
||||
)
|
||||
|
||||
{Perform an action on each "price" element (print it out)}
|
||||
( nestML$(get$("doc.xml",X,ML))
|
||||
: ?
|
||||
( inventory
|
||||
. ?
|
||||
, ?
|
||||
( section
|
||||
. ?
|
||||
, ?
|
||||
( item
|
||||
. ?
|
||||
, ?
|
||||
( price
|
||||
. ?
|
||||
, ?price
|
||||
& out$!price
|
||||
& ~
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
|
|
||||
)
|
||||
|
||||
{Get an array of all the "name" elements}
|
||||
( :?anArray
|
||||
& nestML$(get$("doc.xml",X,ML))
|
||||
: ?
|
||||
( inventory
|
||||
. ?
|
||||
, ?
|
||||
( section
|
||||
. ?
|
||||
, ?
|
||||
( item
|
||||
. ?
|
||||
, ?
|
||||
( name
|
||||
. ?
|
||||
, ?name
|
||||
& !anArray !name:?anArray
|
||||
& ~
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
)
|
||||
?
|
||||
| out$!anArray {Not truly an array, but a list.}
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue