This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27416 - [XP31] Special characters in names
Summary: [XP31] Special characters in names
Status: RESOLVED LATER
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XPath 3.1 (show other bugs)
Version: Last Call drafts
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-24 13:15 UTC by Michael Kay
Modified: 2014-12-02 17:48 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2014-11-24 13:15:08 UTC
XPath is often used to access HTML documents rather than XML documents. HTML5 names allows characters that are not allowed in XML names (for example, '$' is allowed in attribute names, and attribute names can start with a digit). At present the only way to reference such attributes is with the circumlocution *[local-name()='$name'] (and even this requires a violation of contraints in the XDM specification). 

It would be useful to have a defined way to perform queries on XDM instances that aren't constrained by the XML rules on valid element and attribute names. This would also make it easier to map other data models to XDM.

I would therefore propose that

(a) XDM should allow, perhaps in some kind of "non-XML mode", arbitrary strings to appear as element and attribute (local) names

(b) XPath should have some kind of escape mechanism to allow searching for such names. One possibility would be enclosing the string in backticks, e.g. 

@`$name`

Another would be to allow character references to be used in names (which of course would need to be double-escaped when XPath is embedded in XML):

@$name

Another would be to adapt the EQName syntax: N{$name}.

There are other situations where escaped names would be useful: for example calling out to functions in a different programming language, or referencing JSON keys.