functx:change-element-names-deep
Changes the names of elements in an XML fragment
Description
The functx:change-element-names-deep function changes the names of elements that are in $nodes or among their descendants, based on a list of $oldNames to change from, and a list of $newNames to change to. They are positionally related, e.g. the first name in $oldNames is converted to the first name in $newNames. Names that do not appear in the $oldNames list are unchanged.
Each name must be specified as an xs:QName value. QNames can be constructed with calls to the xs:QName type constructor or the fn:QName function, as shown in the examples.
Parameters |
Description |
---|---|
nodes:node() |
|
oldNames:string() |
the sequence of names to change from |
newNames:string() |
the sequence of names to change to |
Examples
XPath |
Results |
---|---|
functx:change-element-names-deep($in-xml-1, xs:QName(‘b’), xs:QName(‘y’)) |
<in-xml> <a> <y>b</y> <c>c</c> </a> </in-xml> |
functx:change-element-names-deep($in-xml-1, (xs:QName(‘a’), xs:QName(‘b’),xs:QName(‘c’)), (xs:QName(‘x’), xs:QName(‘y’),xs:QName(‘z’))) |
<in-xml> <x> <y>b</y> <z>c</z> </x> </in-xml> |
functx:change-element-names-deep($in-xml-2, (xs:QName(‘dty:b’),xs:QName(‘c’)), (xs:QName(‘q’), QName(‘http://new’,’new:c’))) |
<in-xml> <a> <q>b</q> <new:c xmlns:new=”http://new”>c</new:c> </a> </in-xml> |