如何将XSLT转换为XML表单的XML标签/元素中包含空格 [英] How to include space in XML tag/element which gets transformed by XSLT into Excel sheet
问题描述
如何在XML标签/元素中合并空格?我试着把
 
或%20
或#& 20; / code>等(各种语法),但所有这些都显示XML编辑器本身的错误,表示不允许使用此十六进制字符。
我的XML是
< ClientArray>
<客户>
< LastName&Aanonsen< / LastName>
< FirstName> Fred< / FirstName>
<附加备注><附加备注>
< / Client>
我想在附加
和备注
在标签中。
请帮忙。感谢提前。
解决方案
如何在XML
标签/元件?我尝试放置或%20或
&#20;
等。 (各种语法),但是所有这些都显示在xml
编辑器本身上的错误,表示不允许这个十六进制
字符
您不能。 W3C XML规范 严格定义名称的语法名称只能以字母开头(这包括下划线,然后下一个字符可以是字母或数字或连字符,但空格是分隔符,不允许作为任何名称的一部分。
更精确地,这里是 规格的确切规则 :
4a] NameChar :: = NameStartChar | - |。| [0-9] |#xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5]名称:: = NameStartChar(NameChar)*
为了克服这个限制,你必须修改你的XSLT转换,以便它作为Excell列名输出比XML名称更方便的读取字符串。
I have an XML which gets transformed with an XSLT into an Excel sheet on a webpage. The element tags in XML becomes column headers in Excel. There are columns which would like to have spaces. We don't like underscores or hyphens coming in Excel sheet headers.
How can I incorporate space in an XML tag/element? I tried putting  
or %20
or #&20;
etc. (all kinds of syntax) but all of them shows error on XML editor itself saying this hexadecimal character is not allowed.
My XML is
<ClientArray>
<Client>
<LastName>Aanonsen</LastName>
<FirstName>Fred</FirstName>
<Additional Remarks><Additional Remarks>
</Client>
I want a space between Additional
and Remarks
in the tag.
Please help. Thanks in advance.
解决方案
How to I incorporate space in an XML
tag/element? I tried putting or %20 or

etc etc . (all kinds of syntax) but all of them shows error on xml
editor itself saying this hexadecimal
character is not allowed
You can't. The W3C XML specification defines strictly the syntax of names. A name can only start with a letter character (this includes underscore, then the next characters can be letter characters ot numbers or the hyphen, but the space is a delimiter and is not allowed as part of any name.
More precisely, here are the exact rules from the spec:
[4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
[5] Name ::= NameStartChar (NameChar)*
To overcome this restriction you have to modify your XSLT transformation so that it outputs as Excell column names more convenient to read strings than XML names.
这篇关于如何将XSLT转换为XML表单的XML标签/元素中包含空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!