Subject: Re: what are node set fragments and why are they ruining my life? From: "Mark D. Anderson" <mda@xxxxxxxxxxxxxx> Date: Tue, 14 Dec 1999 12:33:50 -0800 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: what are node set fragments and, Phil Lanch | Thread | Re: what are node set fragments and, disco |
RE: dynamically reading tag-names i, Ambarish Chaudhari | Date | Re: what are node set fragments and, disco |
Month |