This question already has an answer here:
- Encoding space character in XML name 2 answers
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.
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:
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.
Besides Dimitre's exact answer, you could use some pattern like in this stylesheet:
With this proper input:
Output:
In XPath 2.0: