Re: [xsl] Is there any xslt 2.0 processor that implements sticky d-o-e

Subject: Re: [xsl] Is there any xslt 2.0 processor that implements sticky d-o-e
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 18 Feb 2013 10:20:19 +0000
On 18/02/2013 08:58, bryan rasmussen wrote:
  as in your example
&lt;title&gt;hello&lt;/title&gt; unescape it

Well of course the actual string content of the node is then


<title>hello</title>

The entities are not there so the "unescape" operation is the function of an xml parser, to turn a string containing xml markup into a node tree.


XPath 3 will have an xml parser as standard, many xpath 1 or 2 systems have an xml parser as extension functions.


A pure xslt way of course is to write the file out in one transfom and then read it back in another.

Or for relatively simple xml-like markup there is a parser written in XSLT available at

http://web-xslt.googlecode.com/svn/trunk/htmlparse/htmlparse.xsl

which you could use as

<xsl:stylesheet version="2.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
		xmlns:d="data:,dpc">


<xsl:import href="http://web-xslt.googlecode.com/svn/trunk/htmlparse/htmlparse.xsl"/>


<xsl:output omit-xml-declaration="yes"/>


<xsl:variable name="data"> &lt;doc&gt; &lt;title&gt;hello&lt;/title&gt; &lt;/doc&gt; </xsl:variable>

<xsl:template name="main">
 <xsl:variable name="pdata" select="d:htmlparse($data,'',false())"/>
 <xsl:value-of select="$pdata/doc/title"/>
</xsl:template>
</xsl:stylesheet>



which produces:


$ saxon9 -it main xp.xsl hello


David


Current Thread