Subject: Re: [xsl] write out '&' instead of '&' From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 18 Jan 2001 09:07:22 +0000 |
Hi Chris, > Using Xalan to do xml to xml transformation. Need write out special > characters as entities, e.g. ' as apostrophe. Now the number is > a variable, but '&#<xsl:value-of select="$entityNumber">;' will not > work in xslt. And I don't want to write '&#<xsl:value-of > select="$entityNumber">;'. What will be the way to get around it? You can't usually control in XSLT the way that characters are outputted - whether they're given as the character itself or a character entity, or whether the character entity is a hex or decimal one. You shouldn't usually want to: those are things to do with the physical document and you should be thinking on a higher plane :) But your situation, where you've got a character number and you want to get a character out, is a bit different. This is what disable-output-escaping is for. First, you *have* to use & instead of '&' whenever you want an ampersand in XML. Otherwise the parser gets all confused and thinks it should find an entity name. If you just do: <xsl:text>&#</xsl:text> <xsl:value-of select="$entityNumber" /> <xsl:text>;</xsl:text> then the XML output will be: &#39; which translates to the string (e.g. displayed in a browser) ' In order to give XML output of: ' you need to tell the XSLT processor not to escape the '&'. You do this through the disable-output-escaping, which can be placed on xsl:text or xsl:value-of. So if you do: <xsl:text disable-output-escaping="yes">&#</xsl:text> <xsl:value-of select="$entityNumber" /> <xsl:text>;</xsl:text> then the XML output will be: ' which translates to the string (e.g. displayed in a browser) ' I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] write out '&' instead of '&am, Sun, Christine (Cah | Thread | Re: [xsl] write out '&' instead of , Michael Beddow |
[no subject], kapil | Date | Re: [xsl] copy all attributes but o, Jeni Tennison |
Month |