xsl-list
[Top] [All Lists]

Re: sort problem

2003-10-19 22:30:37
This was a bug in MSXML4 sometimes ago. It is fixed in the latest two SPs -- 
Using the latest MSXML4 SP I get the correct result.

The latest MSXML4 SP (2) can be downloaded at:


http://www.microsoft.com/downloads/details.aspx?FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42&DisplayLang=en


Besides fixing this and other bugs, I noticed a considerable increase in
speed (twice as much) as compared to the previous SP release.


=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Edward Maesen" <emmt(_at_)nunmeshu(_dot_)com> wrote in message
news:000201c3967f$bd46e9a0$55899dd1(_at_)EMVAIO(_dot_)(_dot_)(_dot_)
I've run into a sort problem with MSXML4 and wonder if it's a bug in that
processor or expected behavior. Basically, the problem seems to be related
to a sort where the select starts at the document node. See stylesheet and
sample XML below.

The stylesheet (sortTest.xsl):
==============================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:template match="/">
<xsl:value-of select="'&#x0A;'"/>
<xsl:apply-templates select="test/content/listgroup"/>
</xsl:template>
<xsl:template match="listgroup">
<xsl:apply-templates select="list">
<!-- the next sort statement is supposed to sort by @pos, but has no
effect in MSXML4. It does work as expected in MSXML3, Xalan 1.4 and Saxon
6.5 -->
<xsl:sort select="/test/data/list[(_at_)ref=current()/@id]/@pos"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="list">
<xsl:value-of select="@id"/> - <xsl:value-of
select="/test/data/list[(_at_)ref=current()/@id]/@pos"/> - <xsl:value-of
select="."/>
<xsl:value-of select="'&#x0A;'"/>
</xsl:template>
</xsl:stylesheet>


The source XML:
===============
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="sortTest.xsl"?>
<test>
<content>
<!-- this is a static pre-defined content section, with list elements that
can be re-ordered by user/session preferences. -->
<listgroup>
<list id="a" name="first">first list in content section</list>
<list id="b" name="second">second list in content section</list>
<list id="c" name="third">third list in content section</list>
<list id="d" name="fourth">fourth list in content section</list>
</listgroup>
</content>
<data>
<!-- this is a session-specific section (appended by an aggregation step
after page request) which contains the desired order of list elements in
the
above content section. -->
<list ref="a" pos="3"/>
<list ref="b" pos="4"/>
<list ref="c" pos="2"/>
<list ref="d" pos="1"/>
</data>
</test>

Expected output:
================
d - 1 - fourth list in content section
c - 2 - third list in content section
a - 3 - first list in content section
b - 4 - second list in content section

Output in MXSML4:
=================
a - 3 - first list in content section
b - 4 - second list in content section
c - 2 - third list in content section
d - 1 - fourth list in content section


In MSXML4 I get the output in document order, in stead of my
desired/expected output. I rewrote the sort select using keys but got the
same result.

I tested in MSXML3, Xalan 1.4 and Saxon 6.5, which gave the desired
result.
Did I run into an MSXML4 bug or did the older processors not implement the
XSLT spec correctly? From reading the spec I don't see why my expected
result would not be allowed so I suspect a bug in MSXML4. Can anybody
confirm? Does anyone have a suggestion for a workaround?

Thanks,
Edward


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>