Created
February 18, 2012 05:44
-
-
Save siahr/1857665 to your computer and use it in GitHub Desktop.
Adds additional attribute to each element on BaseX. (use db:node-id() function)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare function local:appendId($node as node()) { | |
typeswitch($node) | |
case $doc as document-node() | |
return document | |
{for $d in $doc/node() return local:appendId($d)} | |
default | |
return element | |
{node-name($node)} | |
{attribute node-id {db:node-id($node)}, $node/@*, | |
for $child in $node/node() return | |
if ($child instance of element()) | |
then local:appendId($child) | |
else $child | |
} | |
}; | |
local:appendId(fn:doc('bib')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment