Project

Profile

Help

Escape sequence for special characters in XQuery/XPath

Added by Fady Moussallam about 7 years ago

Hello,

Using xQuery with custom input from a JSON origin, we have compilation issues if the element name contains an invalid XML character. In our case, this happens for an element called $date. The dollar sign is not valid for a segment name in XPath.

Was wondering if there is an escape sequence that would allow such element names to be parsed by the xQuery compiler. We tried '$date', '$date' and '%36dat'e but always get a syntax error reported by net.sf.saxon.expr.parser.XPathParser.

Any ideas would be greatly appreciated.

Thank you.

Fady


Replies (1)

RE: Escape sequence for special characters in XQuery/XPath - Added by Michael Kay about 7 years ago

No, sorry. XML element and attribute names have to follow the rules in the XML specification, and there's no way of bending these rules.

This is why the JSON-to-XML conversion defined in the XPath 3.1 specification translates {a:2, b:3} to

23

rather than (say)


  2
  3

Some other JSON-to-XML libraries attempt something like the latter, but they inevitably hit trouble when the JSON key values aren't valid XML names.

    (1-1/1)

    Please register to reply