Re: [xsl] Re: position last and attributes

Subject: Re: [xsl] Re: position last and attributes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 26 Sep 2012 12:32:13 +0100
On 26/09/2012 12:19, Ihe Onwuka wrote:
> On Thu, Sep 20, 2012 at 7:13 AM, Ihe Onwuka
> <ihe.onwuka@xxxxxxxxxxxxxx> wrote:
>> It would seem (somewhat paradoxically) that given the definition
>> of position() and last() they could be applied to @* which is
>> intrinsically unordered.
>
> So seeking to output all the attributes of an element comma
> separated (by all means correct me if I miss the obvious).
>
> If I have done apply-templates select="@*" and have
>
> <xsl:template match="@*"> < code to output the attribute> <!-- do I
> put a comma or not --> <xsl:if test=". is ../@*[last()]>,</xsl:if>


well you could more simply do test="position()=last()" to test if you are the last node being processed in the current sequence. > > the specification doesn't guarantee that ../@* is in the same order > of the node-set returned by @* when the apply-templates was done.

node-set is Xpath 1 terminology. As we tried to explain before the XDM
model over which the stylesheet is operating consists of _ordered_
sequences of nodes. The sequence of attribute nodes for the element is
fixed for the lifetime of the XDM model that was built at parse time, so
each time you select @*[last()] on the same element you get the same
attribute.
>
> So either I have to put the @* in a variable and do my if test on
> that to ensure I am dealing with the same node-set  or I match on
> the parent element instead of @* and for-each through  @* and decide
> where to put my commas that way.

Not really see above.
>
> Or have I got that wrong.
>

I think, yes.

David
--
google plus: https:/profiles.google.com/d.p.carlisle

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread