Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Sort Issue After spawning new nodes >Thread Next - Re: Sort Issue After spawning new nodes Re: Sort Issue After spawning new nodesTo: NULL Date: 9/10/2008 9:09:00 AM I'm still mining your example, but I wanted to post a thank you for answering my question and give you more background as to why I pseudo-coded the example (sorry for that, I know its not ideal). This issue is coming out of MOSS 2007 (Sharepoint), specifically styling a list that has a multivalue field in it. As such, the actual XML code is generated in memory and the XSLT is generated internally by (gulp) Sharepoint Designer. Didn't want to garbage up the forum with that monster. You are using an extension (exslt) that I'm not sure is available to me in Sharepoint... would msxsl have similar functionality? "Martin Honnen" wrote: > Bruce wrote: > > > Now of course, real users want this sorted. I find that I'm running into a > > block here. Any chunk of rows that were originally brokent out of the string > > want to always sort together. I assume xsl:sort is looking past the artifice > > of my fancy footwork and just sorting them where they REALLY are, since the > > result of all this is really just pointers pointing to pointers. How can I > > fool xsl:sort TOO so that it allows me to sort Zebra to the end of the list? > > Sorry, from the information you have provided it is not possible to see > where things go wrong, we would need to see your stylesheet. It should > be possible to create a result tree fragment with new Row elements, then > convert that to a node-set and then to sort that node-set as needed. > > For instance with the XML input being > > <root> > <Row item1="Label" item2="aardvark"/> > <Row item1="Label" item2="echidna;zebra;bear;orangutang"/> > <Row item1="Label" item2="kangaroo"/> > </root> > > and this stylesheet > > <?xml version="1.0" encoding="UTF-8" ?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > xmlns:exsl="http://exslt.org/common" > exclude-result-prefixes="exsl"> > <xsl:output method="xml" indent="yes"/> > <xsl:template match="root"> > <xsl:copy> > <xsl:variable name="row-rtf"> > <xsl:apply-templates select="Row"/> > </xsl:variable> > <xsl:apply-templates select="exsl:node-set($row-rtf)/Row" > mode="copy"> > <xsl:sort select="@item2"/> > </xsl:apply-templates> > </xsl:copy> > </xsl:template> > <xsl:template match="Row" mode="copy"> > <xsl:copy-of select="."/> > </xsl:template> > <xsl:template match="Row[contains(@item2, ';')]"> > <xsl:call-template name="make-rows"> > <xsl:with-param name="row" select="."/> > <xsl:with-param name="items" select="@item2"/> > </xsl:call-template> > </xsl:template> > <xsl:template match="Row[not(contains(@item2, ';'))]"> > <xsl:copy-of select="."/> > </xsl:template> > <xsl:template name="make-rows"> > <xsl:param name="row"/> > <xsl:param name="items"/> > <xsl:choose> > <xsl:when test="contains($items, ';')"> > <xsl:element name="{name($row)}"> > <xsl:copy-of select="@*[not(name() = 'item2')]"/> > <xsl:attribute name="item2"> > <xsl:value-of select="substring-before($items, ';')"/> > </xsl:attribute> > </xsl:element> > <xsl:call-template name="make-rows"> > <xsl:with-param name="row" select="$row"/> > <xsl:with-param name="items" select="substring-after($items, > ';')"/> > </xsl:call-template> > </xsl:when> > <xsl:otherwise> > <xsl:element name="{name($row)}"> > <xsl:copy-of select="@*[not(name() = 'item2')]"/> > <xsl:attribute name="item2"> > <xsl:value-of select="$items"/> > </xsl:attribute> > </xsl:element> > </xsl:otherwise> > </xsl:choose> > </xsl:template> > </xsl:stylesheet> > > the result with Visual Studio 2005 is > > <root> > <Row item1="Label" item2="aardvark" /> > <Row item1="Label" item2="bear" /> > <Row item1="Label" item2="echidna" /> > <Row item1="Label" item2="kangaroo" /> > <Row item1="Label" item2="orangutang" /> > <Row item1="Label" item2="zebra" /> > </root> > > which is sorted properly. > > > > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
