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

Re: [xsl] position last and attributes


Subject: Re: [xsl] position last and attributes
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Thu, 20 Sep 2012 08:45:27 -0400

At 2012-09-20 12:02 +0100, Ihe Onwuka wrote:
On Thu, Sep 20, 2012 at 11:47 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
>
> On 20/09/2012 07:13, Ihe Onwuka wrote:
>>
>> It would seem (somewhat paradoxically) that given the definition of
>> position() and last() they could be applied to @* which is
>> intrinsically unordered.
>>
>
> Actually, there is a total ordering relation (document order) over all
> nodes. It's just that for two attributes of the same element (and indeed,
> say, for two elements in different documents) the ordering relation is
> implementation-dependent. So it's not correct to say that they are
> "intrinsically unordered". They are ordered, but not in a predictable way.
>

Then to me, they are not ordered irrespective of what the implementation does.

Waking up in North America to find such a long discussion is fascinating ... I think this could have been nipped in the bud early on.


Would it not have helped to cite a specification?

  http://www.w3.org/TR/2004/REC-xml-infoset-20040204/#omitted
  Appendix D: What is not in the Information Set (normative)
  The following information is not represented in the current version
  of the XML Information Set (this list is not intended to be
  exhaustive):
  ...
  10.The order of attributes within a start-tag.

So, the specification on which XPath is based normatively specifies that attributes are not ordered ... it isn't something that you have to "believe".

The building of the XPath data model then allows any implementation to build the XPath node tree in any order it wants for the attributes of an element, thus the attribute nodes attached to an element node are built in an arbitrary order.

I saw a lot of comments talking about "[1]" and "[last()]" talking about attributes, and I think that is the problem regarding the discussion: The predicate "[1]" and "[last()]" is *not* based on the markup (attributes), but rather is based on the order of nodes in the XPath data model (attribute nodes). An XDM tree is read-only once it is created, thus, the order of nodes in the data model is reliable once the data model is built.

And nowhere in the discussion did I see anyone mention that defaulted attributes from the DTD or schema are included in the building of attribute nodes attached to an element ... would that not have messed up any discussion of "[1]" and "[last()]" with respect to specified attributes? If the start tag has three attribute specifications and the schema declaration of the element has an additional two attribute default values, there are five attribute nodes attached to the element. "last()" returns "5", not "3", and "[1]" thus "[last()]" cannot be discussed based only on start tag attribute specifications.

I hope this is regarded as helpful, and I apologize in advance if I've missed something already addressing this in the long thread of messages.

. . . . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


Current Thread
Keywords