At 2004-06-21 15:15 -0400, April Fleming wrote:
Sorry,
No apology necessary ... just trying to figure out what was happening when
you said it "does not work".
When I say it does not work, I mean it does not sort by that attribute.
When the order by value is an attribute that exists in every row (ie. Ip,
device_name) then the results are sorted by that attribute, however, if the
order by value is "device_os" which does not exist in every row, the data
comes back unsorted.
Would you agree that the data comes back in document order for those nodes
where the attribute is absent?
I would like for it to treat the nonexistent attributes
as attribute="", as you say that the standard defines, unfortunately that is
not what it is doing.
Such nodes will sort before attributes with string values, and in the group
of the nodes where the attribute is absent they will be handled in document
order.
Wait ... I just looked at your original post again, and it looks like I
missed something in the haste of my earlier response:
At 2004-06-21 14:50 -0400, April Fleming wrote:
<xsl:template match="rs:data">
<xsl:comment>Loop over the rows in the recordset</xsl:comment>
<xsl:for-each select="z:row">
<xsl:sort select="z:row/@*[name()=$orderBy]"/>
You seem to be selecting the rows to be sorted, and then sorting them by a
non-existent node. Note how your select is referencing a child z:row of
the z:row node being selected ... yet looking at your data, the z:row is an
empty element ... perhaps you missed that the sort expression evaluation is
done based on the node being sorted and not the current node when the
selection was made.
I recommend you try select="@*[name()=$orderBy]" to see if you then get the
desired results ... though your original code should not have worked even
for nodes where the attribute is present, so I'm surprised you haven't
always had problems with this code fragment.
I hope this helps.
.......................... Ken
--
Public training 3 days XSLT & 2 days XSL-FO: Phoenix,AZ 2004-08-23
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal