Altova Mailing List Archives


Re: what are node set fragments and why are they ruining my life?

From: "Mark D. Anderson" <mda@-------------->
To:
Date: 12/14/1999 4:34:00 AM
Some follow-ups:

- sorry, i meant "result tree fragments", not "node set fragments".
But they are still ruining my life.

- I still don't get what is different between a rtf and
a node-set. I mean, I get that a rtf is on the result side
and the node-set is on the input side. But how could a rtf
not be a set of nodes? Under what circumstances will
xt:node-set or sxf:node-set fail?
I certainly don't see why merely passing something through
a variable (as in my example) should make it not convertible,
since it started out as the result of a select expression
after all.

- Phil Lanch and David Carlisle suggest using
<xsl:for-each select="xt:node-set($members)">
      <xsl:message>again member ... <!-- insert word "again" to distinguish later xsl:message -->
rather than just plain "$members".

in xt, this results in:
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:2: member local-name=member, id=1
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:3: member local-name=member, id=2
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xsl:1: again member local-name=, id=
member 1

Note that now xt is executing two xsl:message instructions in the named
template, and just one (presumably for the root?) in the main template.
So this means that i did not get back the same node set ($results) that
i started with when i went through $results -> $members -> xt:node-set($members).
I'd like to get back what I started with. I don't see why passing things 
through call-template calls and variables and value-of should change them.

Note that if I change the xsl:value-of at the end of the
named template to a xsl:copy-of, I then get this from xt:
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:2: member local-name=member, id=1
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:3: member local-name=member, id=2
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xsl:1: again member local-name=, id=
member 1member 2

If I also change the xsl:value-of at the end of the main template, I get:
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:2: member local-name=member, id=1
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:3: member local-name=member, id=2
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xsl:1: again member local-name=, id=
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:2: member local-name=member, id=1
file:/d:/mda/projects/xmlhacks/xmlidl/test1.xml:3: member local-name=member, id=2
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<member id="1">member 1</member><member id="2">member 2</member>

But even though I can do a <xsl:copy-of select="$members"/> in the main template,
<xsl:for-each select="$members"> gives me a "cannot convert to node-set" error,
and <xsl:for-each select="xt:node-set($members)"> has only 1 loop pass, not 2.

saxon produces this:
member local-name=member, id=1
member local-name=member, id=2
again member local-name=, id=

<member id="1">member 1</member>
<member id="2">member 2</member>
(note different number of xsl:message calls, and lack of doctype and different
white space treatment. who knows what is right....)


- I agree with Phil that both xt and saxon have a bug here.
xt for not executing enough xsl:message instructions, and saxon for
producing no result.

- Michael Kay asks what I'm trying to do. The example i gave was a
distilled trivial example of a far more complex page I'm doing.
I have a god-awful select expression that I want to re-use in various
places. I could use an ENTITY, but i'd rather just modularize by
using a call-template -- have a named template return the node set
from the messy select, and then do a for-each or an apply-templates
on a variable which has the value returned by that named template
(alas, for-each and apply-templates only take a select attribute,
so i can't just have the applied to a call-template result directly).

- Phil Lanch also suggested that the reason i got a tree frag was
because i initialized the variable $members with content rather
than a select. But how could I do otherwise, when I want to
set it to the result of a call-template?

-mda


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

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.