Converts any string to a valid NCName, by escaping characters that would otherwise be invalid.
escape-NCName($input as xs:string) ➔ xs:NCName
The input string to be converted
Requires Saxon-PE or Saxon-EE. Implemented since Saxon 11.
Notes on the Saxon implementation
Available since Saxon 11.
If the supplied string is a valid NCName, it is returned unchanged.
The zero-length string is converted to a single underscore,
An underscore is converted to a pair of underscores,
A character that would not be valid in an NCName (or, if it is the first character,
at the start of an NCName) is converted to the form
is the shortest hexadecimal representation of the Unicode codepoint. For example,
"_a3_". Lower case is used for digits a-f.
The rules for NCName characters are those in XML 1.0 Fifth Edition (which match the rules in XML 1.1).
saxon:escape-NCName("date of birth") returns
The function is primarily intended for use when converting JSON to XML.
The reverse conversion is available from the function