Subject: Re: [xsl] character entities From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 20 Nov 2001 12:15:20 +0000 |
David C. wrote: > XSLT requires all entities to be expanded. > If you don't need to query into the replacement texts of the entities > and want to use XSLT, you need to use something that removes the &'s > here's a script I use: Another quick possibility, if the entities are the same as the HTML entities, is to use the HTML output method with Saxon. (MSXML, which I think is the default with XML Spy, outputs characters as decimal character references rather than character entity references, as does Xalan from what I can tell.) As long as the XML that you're generating doesn't contain any elements that have the same name as the empty HTML elements (e.g. br, img, meta, link) or the ones that have CDATA content (e.g. script, style) then you should get the same as the XML output method but with entities escaped (I think). Alternatively, you might be able to switch to Xalan and use the xalan:entities extension attribute on xsl:output to point to a resources file that lists the mappings between character numbers and entities. You could take HTMLEntities.res in org.apache.xalan.serialize as a starting point. Or if you're feeling really brave, you could write your own serializer. You can write one in Java for Saxon or Xalan, and just plug it in through the stylesheet, or if you wanted to use MSXML you could write a script that does the transformation into a DOM and then serialize the DOM with the appropriate substitutions in the text nodes. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] character entities, David Carlisle | Thread | Re: [xsl] character entities, David Carlisle |
Re: [xsl] character entities, David Carlisle | Date | Re: [xsl] character entities, David Carlisle |
Month |