This question already has an answer here:
这个问题在这里已有答案:
- Encoding space character in XML name 2 answers
在XML名称2答案中编码空格字符
How do I add a space in an XML schema element? I'd like to have "Last Name" without using an underscore. Thanks.
如何在XML架构元素中添加空格?我想在不使用下划线的情况下使用“姓氏”。谢谢。
<xs:element name="Last Name" type="xs:string" minOccurs="0" />
2 个解决方案
#1
You can't. That would go against the XML specification. The space character is used as a delimiter in XML and has special meaning. It cannot appear in element names.
你不能。那将违反XML规范。空格字符用作XML中的分隔符,具有特殊含义。它不能出现在元素名称中。
Think about the resulting element that you would be defining with that declaration:
考虑一下您将使用该声明定义的结果元素:
<Last Name attribute1="value" attribute2="value">Contents</Last Name>
That doesn't look anything like XML and would be rejected by any XML parser.
这看起来不像XML,并且会被任何XML解析器拒绝。
#2
this schema represents an element in XML. Elements are not allowed to have white spaces in their names as they are used as a delimiter for attributes.
此架构表示XML中的元素。元素不允许在其名称中包含空格,因为它们用作属性的分隔符。
#1
You can't. That would go against the XML specification. The space character is used as a delimiter in XML and has special meaning. It cannot appear in element names.
你不能。那将违反XML规范。空格字符用作XML中的分隔符,具有特殊含义。它不能出现在元素名称中。
Think about the resulting element that you would be defining with that declaration:
考虑一下您将使用该声明定义的结果元素:
<Last Name attribute1="value" attribute2="value">Contents</Last Name>
That doesn't look anything like XML and would be rejected by any XML parser.
这看起来不像XML,并且会被任何XML解析器拒绝。
#2
this schema represents an element in XML. Elements are not allowed to have white spaces in their names as they are used as a delimiter for attributes.
此架构表示XML中的元素。元素不允许在其名称中包含空格,因为它们用作属性的分隔符。