[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Special character as element name


Subject: Re: [xsl] Special character as element name
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 25 Jan 2007 09:55:32 +0100

Deborah Pickett wrote:
San wrote:
<Body ID="2" >
  <#x/>
</Body>

Actually a hash, U+0023? I'm afraid that's not allowed in XML: http://www.w3.org/TR/REC-xml/#NT-Name and a conforming XSLT processor isn't going to help you to create it.

If you really must have that format (it's not XML any more), you will have to add a postprocessing stage using some other, XML-ignorant, language.

I am under the impressions that the OP means to replace #x with something like &#xED; or something similar. Which is neither allowed, you cannot have character entities as the name for the tag. If he actually mean a "special character" being something other than US-ASCII, this *is* allowed, and can be created. Even if the xsl:element instruction contains character entities:


<xsl:element name="#&xDA;" />

or

<xsl:element name="{@URI}" />

(though I can hardly believe that a URI, if it is a URI, won't have other illegal qName characters, like '/', '%' etc.)

If the OP means he wants to create XML output that is not XML, there is the option (though highly discouraged) to create output as Text. However, in that case it is Text, not XML anymore, and xsl:element won't help you, you will have to create the 'element'-like text piece by piece by hand. (using XSLT 2 there's another trick with character-maps, but still, it is *not* XML anymore).

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl


Current Thread
Keywords