Hello I'd like handle Xml-Files which have encoded node names like for example:
<CST_x002F_SOMETHING>
....
</CST_x002F_SOMETHING>
This node name should be decoded to CST/SOMETHING.
These node names were encoded for example via EncodeName. Is there any built-in XQuery-function to decode these names? Or do you have an encoding / decoding function?
XML Files produced by Oracle-DB use the same escaping mechanism.
Use
fn:analyze-string()to split the string and match the_XXXX_parts. When you encounter one of these parts, usebin:hex()to convert hex to binary, thenbin:unpack-unsigned-integer()to convert the binary to an integer, thenfn:codepoints-to-string()to convert the integer codepoint to a string.The binary functions are documented at https://www.saxonica.com/documentation/index.html#!functions/expath-binary
Requires Saxon-PE or higher.
You could also use the new saxon:replace-with() function:
outputs
CST/SOMETHING