[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] position last and attributes

Subject: Re: [xsl] position last and attributes
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Thu, 20 Sep 2012 18:00:14 +0530

Hi Ihe,

On Thu, Sep 20, 2012 at 4:05 PM, Ihe Onwuka <ihe.onwuka@xxxxxxxxxxxxxx> wrote:
> the same way that I say that applying an ordering semantic to
> something that is unordered is paradoxical.

As has been discussed, the position() and last() functions have
ordering semantics that relates to the instance sequence (which most
likely exists in a XSLT stylesheet at run-time). This ordering is not
related to the document order of an XML instance.

Also, a sequence may contain heterogeneous collection of items (like
elements, attributes, atomic values all in one sequence). For e.g, if
you do,

<!-- iterate elements and attributes together -->
<xsl:for-each select="elem | @*">
    <xsl:value-of select="position()"/>

Then the value of position() in this case, is the position of context
item (which could be an element or attribute).

Mukul Gandhi

Current Thread