有没有办法在[xml元素名称中包含] [字符?
例如
<AWSECommerceService.ItemSearch.ItemSearch.Request[0].SearchIndex>Electronics</AWSECommerceService.ItemSearch.ItemSearch.Request[0].SearchIndex>使用它的原因是在SVG中,隐藏请求输入值是使用名称指定请求键的xml元素指定的。
例如:
<xforms:model id="form1"> <xforms:instance> <q>toyota</q> </xforms:instance> <xforms:submission id="submit1" xforms:method="get" xforms:action="http://www.google.ca/search" />会产生对http://www.google.ca/search?q=toyota的请求
Is there any way to include the [ character in an xml element name?
For example
<AWSECommerceService.ItemSearch.ItemSearch.Request[0].SearchIndex>Electronics</AWSECommerceService.ItemSearch.ItemSearch.Request[0].SearchIndex>The reason for using this is that in SVG hidden request input values are specified using xml elements whose name specifies the request key.
For example:
<xforms:model id="form1"> <xforms:instance> <q>toyota</q> </xforms:instance> <xforms:submission id="submit1" xforms:method="get" xforms:action="http://www.google.ca/search" />would result in a request to http://www.google.ca/search?q=toyota
最满意答案
你不能 - 它不是XML元素名称的有效部分。
从规格 :
ASCII符号和标点符号以及相当大的一组Unicode符号字符从名称中排除,因为它们在XML文档外部使用XML名称的上下文中更有用作为分隔符。 提供此组为这些上下文提供了有关不能成为XML名称一部分的内容的硬性保证。
然后BNF遵循允许的内容:
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] Name ::= NameStartChar (NameChar)* Names ::= Name (#x20 Name)* Nmtoken ::= (NameChar)+ Nmtokens ::= Nmtoken (#x20 Nmtoken)*You can't - it's not a valid part of an XML element name.
From the spec:
The ASCII symbols and punctuation marks, along with a fairly large group of Unicode symbol characters, are excluded from names because they are more useful as delimiters in contexts where XML names are used outside XML documents; providing this group gives those contexts hard guarantees about what cannot be part of an XML name.
There then follows BNF for what is allowed:
NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040] Name ::= NameStartChar (NameChar)* Names ::= Name (#x20 Name)* Nmtoken ::= (NameChar)+ Nmtokens ::= Nmtoken (#x20 Nmtoken)*更多推荐
发布评论