|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] adding elementsWolfgang Meier wolfgang at exist-db.orgFri Dec 18 12:16:20 PST 2009
Hi Jens,
as an alternative to using XSLT or XQuery Update, my standard XQuery
solution would be to create a recursive filter function with a
typeswitch statement. Tested with saxon:
declare namespace dc="http://purl.org/dc/elements/1.1/";
declare variable $xml :=
<object id="O33051">
<view id="V33052">
<original filename="374.jpg"
hash="a72ff5300a4e5cba7c6d58d581f7c220"/>
<img height="141" src="img/V33052.original" use="pict" width="213"/>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description
rdf:about="petal://kjc-fs2.kjc.uni-heidelberg.de:8081/HIEditor_2.0-Service/P67/V33052"
xml:lang="en">
<dc:title>daṃtahastavināyaka</dc:title>
<dc:source/>
</rdf:Description>
</rdf:RDF>
</view>
</object>;
declare function local:modify($title as element(dc:title)) {
<dc:title xml:lang="xx">{$title/text()}</dc:title>
};
declare function local:filter($node as node()) {
typeswitch ($node)
case element(dc:title) return
($node, local:modify($node))
case element() return
element { node-name($node) } { $node/@*, for $child in
$node/node() return local:filter($child) }
default return
$node
};
local:filter($xml)
Wolfgang
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






