Subject: Re: [xsl] Fwd: Parsing Entities From: David Carlisle <davidc@xxxxxxxxx> Date: Tue, 10 Jan 2006 13:00:06 GMT |
I've looked at saxon:parse (http://www.saxonica.com/documentation/extensions/functions/parse.html) though that seems specific to CDATA and expects a single root node XML document. Not sure what you mean by "specific to CDATA". XSL doesn't have anything of type CDATA, and saxon:parse() just requires a string which you can easily extract out of your text node. You need to make sure it's well formed XML so has a single top level element (note this is not the root node, it is the _child_ of the root node), so you can concatenate the element content with a start and end tag, parse, then extract the contents of the element: saxon:parse(concat('<x>',letter_text,'</x>'))/x/node() > though I'm aware that XSLT isn't really > very good for text processing. XSL2 is a lot better than XSLT1 (for instance it would be fairly easy to parse that amount of escaped xml, just using xsl without any extensions. for example: parse.xml <letter_text><p>Some random letter text :(.</p><p>Will this work?</p></letter_text> parse.xsl <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="data:,dpc" version="2.0"> <xsl:import href="http://www.dcarlisle.demon.co.uk/htmlparse.xsl"/> <xsl:output method="xml"/> <xsl:template match="letter_text"> <xsl:copy-of select="d:htmlparse(.,'',false())"/> </xsl:template> </xsl:stylesheet> $ saxon8 parse.xml parse.xsl <?xml version="1.0" encoding="UTF-8"?><p>Some random letter text :(.</p><p>Will this work?</p> ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Fwd: Parsing Entities, Kaila Kaarle | Thread | RE: [xsl] Fwd: Parsing Entities, Kaila Kaarle |
RE: [xsl] Fwd: Parsing Entities, Michael Kay | Date | Re: [xsl] substring, David Carlisle |
Month |