xsl-list
[Top] [All Lists]

[xsl] outputting an ampersand in an attribute

2009-08-05 17:00:18
I am generating svg documents and would like to output an element like:

<glyph unicode="&#xE003;" horiz-adv-x="833" 
d="M124,348L124,249L709,249L709,348L124,348 Z"/>

I need to generate the value of @unicode programmatically. The difficulty, of 
course, is outputting the ampersand in @unicode.

I started off by trying to disable output escaping:

<xsl:variable name="char" as="xs:string">
  <xsl:value-of disable-output-escaping="yes" 
      select="concat(codepoints-to-string(38), position(), ';')"/>
 </xsl:variable>
<xsl:attribute name="unicode" select="$char"/>

But this came out as &amp;
(followed by an integer and ; per the concat())

I then tried to use character maps:

<xsl:character-map name="charmap">
   <xsl:output-character string="&amp;" character="&"/>
</xsl:character-map>

But the processor refuses to accept the lone ampersand in @character. It 
generates the following message:

"The entity name must immediately follow the '&' in the entity reference."

But since the entity name is generated at runtime, I have a problem.

Any thoughts are greatly appreciated...

Tom




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--