|
Subject: Re: [xsl] accessing last element of node set passed as parameter From: "paul morgan" <pmorg@xxxxxxxxx> Date: Tue, 21 May 2002 11:40:33 -0700 |
Thanks David! Some of this is starting to click ... but then again something happens that shuts the clicker down.
Since order is important to me, I decided to heed your warning about the ordering of a union being implementation dependent, so I set about making all of the "BAR" elements be siblings of one another. I replaced:
<xsl:apply-templates select="following-sibling::*[1]">
<xsl:with-param name="result" select="$result|xalan:nodeset($new)"/>
</xsl:apply-templates> </xsl:template>
with:
<xsl:apply-templates select="following-sibling::*[1]">
<xsl:with-param name="result">
<xsl:copy-of select="$result"/>
<BAR i="{$i}"/>
</xsl:with-param>
</xsl:apply-templates> </xsl:template>
but now I get the following error message:
Can not convert #RTREEFRAG to a NodeList!
at the line:
<xsl:copy-of select="($result/BAR)[last()]" />
the first time the "A" template is matched with a non-empty value for "result". Shouldn't "result" be a node set?
Paul (I think this language is going to make my head explode)
--
On Tue, 21 May 2002 18:09:50
David Carlisle wrote:
>
>
> produce identical output given the input:
> <IN><A/><A/><A/><A/><A/><A/></IN>
>
> Below is a transform in which the two lines:
>
> <xsl:copy-of select="($result/BAR)[last()]" />
> <xsl:copy-of select="$result[last()]" />
>
>
> "$result|xalan:nodeset($new)"/>
>
>Ha! I guessed two possible meanings:
>
>
>
>> But they can not have done. If $result holds a root node then
>> $result/BAR
>> selects all the BAR children of that node and
>> ($result/BAR)[last()]
>> selects the last of those children.
>>
>> But if $result contains three BAR nodes then
>>
>> $result/BAR
>>
>> selects all the BAR children of each element of $result, and that is
>> empty so ($result/BAR)[last()] is similarly empty.
>>
>>
>
>But in fact you have a third.
>
>$result in this case contains three _root_ nodes so $result does have
>three nodes, so <xsl:copy-of select="($result/BAR)[last()]" does pick
>out the last. But they are root nodes not BAR nodes so
>"($result/BAR)[last()]" gives you the last BAR.
>Since copy-of throws away root nodes and just gives you thier contents,
>you do get the same.
>
>Note however that it is undefined which one you get, you are taking the
>union of a new root node with a set of existing root nodes. Root nodes
>are in an implementation defined order so you can not be sure that the
>last one you added is the one you get with last().
>
>If the order matters you need to make sure your bar elements are
>siblings of each other, then the result variable will have a single root
>node containing the elements that you are interested in.
>
>David
>
>_____________________________________________________________________
>This message has been checked for all known viruses by Star Internet
>delivered through the MessageLabs Virus Scanning Service. For further
>information visit http://www.star.net.uk/stats.asp or alternatively call
>Star Internet for details on the Virus Scanning Service.
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
________________________________________________________
Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] accessing last element of, David Carlisle | Thread | Re: [xsl] accessing last element of, Joerg Heinicke |
| RE: [xsl] Grouping question, bryan . s . schnabel | Date | Re: [xsl] accessing last element of, Joerg Heinicke |
| Month |