Yes, the nodes should be returned in document order, not in the order of the supplied ID values.
In fact strictly speaking XPath 1.0 always returns a node-set, that is a collection of nodes in no particular order, and XSLT 1.0 always processes node-sets in document order regardless how they are produced.
Michael Kay

From: [] On Behalf Of Gabriel McGoldrick
Sent: 10 September 2004 11:02
Subject: [saxon] Are nodes returned by id() always in document order?

Should the id() function return nodes in the order of the id values or in document order?
Below is a some XML, XSL and output that appears to show the nodes being returned in document order rather than the oder of the values specified in the call to id()
Using Saxon 6.5.3 on Windows XP
<xref target="mmc003-bib-0055 mmc003-bib-0054" style="unformatted"/>
<bib id="mmc003-bib-0054">
<author><surname>Smith</surname> <forenames>AL</forenames></author>
<articleTitle>Mouse parvovirus infection potentiates allogeneic skin graft rejection and induces syngeneic graft rejection</articleTitle>.
<bib id="mmc003-bib-0055">
<author><surname>McKisic</surname> <forenames>MD</forenames></author>,
<articleTitle>Mouse parvovirus infection potentiates rejection of tumor allografts and modulates T cell effector function</articleTitle>.
<xsl:variable name="idrefs" select="normalize-space(@target)"/>
<xsl:message>idrefs= <xsl:value-of select="$idrefs"/></xsl:message>

<xsl:variable name="remote-nodes" select="id($idrefs)"/>

<xsl:for-each select="$remote-nodes">
  <xsl:message>id= <xsl:value-of select="./@id"/></xsl:message>
idrefs= mmc003-bib-0055 mmc003-bib-0054

id= mmc003-bib-0054
id= mmc003-bib-0055