[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: outputting an ampersand in an attribute
You can do it with character maps but you don't need to do anything as messy as that. You want an attribute containing the Unicode character with code point xE003 (= decimal 57347), so write <xsl:attribute name="unicode" select="codepoints-to-string(57347)"/> and let the serializer do its job of serializing it: that's what it's good at. Regards, Michael Kay http://www.saxonica.com/ http://twitter.com/michaelhkay > -----Original Message----- > From: tom a [mailto:tasmito@xxxxxxxxx] > Sent: 05 August 2009 22:00 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: outputting an ampersand in an attribute > > I am generating svg documents and would like to output an > element like: > > <glyph unicode="" 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 & > (followed by an integer and ; per the concat()) > > I then tried to use character maps: > > <xsl:character-map name="charmap"> > <xsl:output-character string="&" 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|