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

Subject: Re: what are node set fragments and why are they ruining my life?
From: "Mark D. Anderson" <mda@xxxxxxxxxxxxxx>
Date: Sat, 18 Dec 1999 11:03:54 -0800
Thanks to everyone who has helped. I do now have something working, though
since I don't understand exactly why it works and other things don't,
I'm still questioning....

David Carlisle wrote:

>> - Phil Lanch and David Carlisle suggest using
>> <xsl:for-each select="xt:node-set($members)">
> 
> well I said that this extension could be used to get back a node set,
> but probably (if I understood quite what you want to do, which I don't)
> you wouldn't need this as you could avoid building a result tree
> fragment too early (which appears to be your problem)
> 
>> 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,
> 
> That's to be expected.

Maybe something just penetrated my skull:

the error "cannot convert to node-set" does *not* mean that if I wrapped
a "xt:node-set" around it, that would also fail. It just means that
the thing as it stands is not a node-set. It isn't really trying to
convert a RTF to a node set, because the spec says it doesn't have to try.

I'm still unclear *why* merely passing through a call-template and
a variable is enough to make an xpath no longer be a node set -- with
no real "transformation" happening -- but i can work around it if those
are the rules of the game.

on a related note, i'm mystified why xsl:variable can take element
content as an alternative to a select attribute, but for-each (and
xsl:if, and xsl:when, and xsl:attribute, ...) don't
allow this wonderful convenience. That is part of what got me to
this problem to begin with.

>> and <xsl:for-each select="xt:node-set($members)"> has only 1 loop
>> pass, not 2.
> well node-set isn't standard of course, but probably it is putting a
> root node on it, so in that case you probaly want
>   "xt:node-set($members)/*"

bingo, that works!

> 
>> 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 
> 
> so why not just do that?
> 
> If you have
> 
> <xsl:template name="god-awful">
>   <xsl:apply-templates
>      select="foo|a/b[@xx]/c[@aa and @dd='this']|aa[dd[cc]]"/>
> </xsl:template>
> 
> 
> then you can just use
> 
> <xsl:call-template name="god-awful"/>
> 
> whenever you want to do an apply based on that select expression in some
> other template.

Because it is the select phrase that i want to re-use, not the processing:
there are 3 different kinds of processing that i want to do to the
node set described by the god-awful select phrase.
in effect, i want to say something like:
 doit1($awful)
 doit2($awful)
 doit3($awful)

except it isn't that simple -- i can't just put doit1 doit2 doit3 in
one doitall template.

-mda




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


Current Thread