Subject: RE: [xsl] sort problem From: "Robert Koberg" <rob@xxxxxxxxxx> Date: Sun, 19 Oct 2003 14:22:20 -0700 |
Hi Ed (how are things? Long time no speak :), As to a work around I would do something like: ... <xsl:apply-templates select="/test/data/list"> <xsl:sort select="@pos"/> </xsl:apply-templates> ... <xsl:template match="list"> <xsl:variable name="id" select="@id"/> <xsl:apply-templates select="/test/content/listgroup/list[@id=$id]"/> </xsl:template> This should work in all... Best, -Rob > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl- > list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Edward Maesen > Sent: Sunday, October 19, 2003 1:30 PM > To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx > > 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="'
'"/> > <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[@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[@ref=current()/@id]/@pos"/> - <xsl:value-of > select="."/> > <xsl:value-of select="'
'"/> > </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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] sort problem, Edward Maesen | Thread | [xsl] Encoding while parsing, Pramodh Peddi |
[xsl] sort problem, Edward Maesen | Date | RE: [xsl] sort problem, Michael Kay |
Month |