如何将XSLT转换为XML表单的XML标签/元素中包含空格 [英] How to include space in XML tag/element which gets transformed by XSLT into Excel sheet

查看:129
本文介绍了如何将XSLT转换为XML表单的XML标签/元素中包含空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个XML,它被XSLT转换成一个页面的Excel表格。 XML中的元素标签在Excel中成为列标题。有一些列要有空格。我们不喜欢下划线或连字符来自Excel表格标题。
如何在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 &#032; 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 &#20; 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆