Created
August 22, 2012 07:29
-
-
Save KitWallace/3423421 to your computer and use it in GitHub Desktop.
Recursive invert a stick
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:invert($stick) { | |
let $leaf := $stick//*[last()] | |
return local:invert1($leaf) | |
}; | |
declare function local:invert1($leaf) { | |
if (exists($leaf)) | |
then element {name($leaf)} { | |
local:invert1($leaf/..) | |
} | |
else () | |
}; | |
let $x := <a><b><c><d/></c></b></a> | |
return local:invert($x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment