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

Re: Result tree fragment to string?

Subject: Re: Result tree fragment to string?
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 28 Aug 2008 12:31:27 +0200
Re:  Result tree fragment to string?
Houghton,Andrew wrote:

The above doesn't handle namespaces, processing-instructions,
comments,
or mixed content, but it could be hacked to do so.  Is there a reason
why this approach would not work in XSL 1.0 to satisfy his needs?
Yes, the reason is that you can't do the apply-templates on the result
tree fragment, you would first need to convert it to a node-set with an
extension function.

Oops, I thought his result tree was a node set, not a string...

A result tree fragment is not a string but it is also not a node set.


If you have e.g.

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">

  <xsl:template match="/">
    <xsl:variable name="rtf">
      <html>
        <body>
          <p>Example</p>
        </body>
      </html>
    </xsl:variable>
    <xsl:apply-templates select="$rtf" mode="m1"/>
  </xsl:template>

  <xsl:template match="/" mode="m1">
    <xsl:copy-of select="."/>
  </xsl:template>

</xsl:stylesheet>

then for instance Saxon 6.5 will complain "Error at xsl:apply-templates on line 13 [...]. Cannot process a result tree fragment as a node-set under XSLT 1.0".

--

	Martin Honnen
	http://JavaScript.FAQTs.com/

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.