[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Fwd: Parsing Entities

Subject: Re: Fwd: Parsing Entities
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 10 Jan 2006 13:00:06 GMT
saxon parse
  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>&lt;p&gt;Some random letter text :(.&lt;/p&gt;&lt;p&gt;Will
this work?&lt;/p&gt;</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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.