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

what are node set fragments and why are they ruining my life

Subject: what are node set fragments and why are they ruining my life?
From: "Mark D. Anderson" <mda@xxxxxxxxxxxxxx>
Date: Mon, 13 Dec 1999 20:13:57 -0800
fragments of my life
see the minimal xsl and xml file below.

first off, nothing i've read in the spec or the various xsl tutorials
make any sense in defining what a node set fragment is.
they talk about things like "not being well-formed", but (a) i'm not
clear how one is able to produce something that isn't well-formed,
and (b) that doesn't match experience as this example shows.

here i've shown where the mere act of passing a node set (fragment)
through a call-template is enough to defile it.

here are the various outputs.

1. comment out first for-each, use xt
output is:
member 1

note that there is a result, but no xsl:message instructions are run

2. comment out first for-each, use saxon
output is:
member local-name=member, id=1
member local-name=member, id=2

note that there is no result, but the xsl:message instructions are run

3. leave in first for-each, use xt
output is:
cannot convert to node-set

4. leave in first for-each, use saxon
member local-name=member, id=1
member local-name=member, id=2
Error during source document processing
At xsl:for-each on line 32 of file:/d:/mda/projects/xmlhacks/xmlidl/test1.xsl: Cannot convert value [** RESULT TREE FRAGMENT **] to
a node-set

Thanks to anyone who can elucide this matter.

-mda

test1.xml

<root>
  <member id="1">member 1</member>
  <member id="2">member 2</member>
</root>


test1.xsl

<?xml version="1.0" ?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:date="http://www.jclark.com/xt/java/java.util.Date"
  xmlns:xt="http://www.jclark.com/xt"
  xmlns:sxf="/com.icl.saxon.functions.Extensions"
  extension-element-prefixes="date xt sxf"
  exclude-result-prefixes="date sxf xt"
  >
  <xsl:output
     method="html"
     indent="yes"
     doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"
  />
  <xsl:strip-space elements="*"/>

  <xsl:template match="root">
    <xsl:variable name="members">
      <xsl:call-template name="get_members"/>
    </xsl:variable>
    <!-- why can't i use a variable? something about result tree fragments... -->

    <!-- comment this for-each out to avoid the runtime error
    <xsl:for-each select="$members">
      <xsl:message>member local-name=<xsl:value-of select="local-name(.)"/>, id=<xsl:value-of select="@id"/></xsl:message>
    </xsl:for-each>
    -->
    <xsl:value-of select="$members"/>
  </xsl:template>

  <xsl:template name="get_members">
    <xsl:variable name="result" select="*"/>
    <xsl:for-each select="$result">
      <xsl:message>member local-name=<xsl:value-of select="local-name(.)"/>, id=<xsl:value-of select="@id"/></xsl:message>
    </xsl:for-each>
    <!-- same thing as: <xsl:value-of select="$result"/> -->
    <xsl:value-of select="*"/>
  </xsl:template>

</xsl:stylesheet>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.