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

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

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
cannot convert to node set
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

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.