|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Sorting & Grouping
Mike, I don't work. If I use AXIS it checks preceding in document order but the check needs to be done in sorted order. I used test=name(preceding-sibling::*[1])!= name() and O/P is Type C Type B Type B Type A Intended o/p Type C Type B SAME Type A The XSL I used is <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="parent/*"> <xsl:sort select="id"/> </xsl:apply-templates> </xsl:template> <xsl:template match="typeA"> <xsl:choose> <xsl:when test="name(preceding-sibling::*[1])!= name()"> Type A </xsl:when> <xsl:otherwise> Same </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="typeB"> <xsl:choose> <xsl:when test="name(preceding-sibling::*[1])!= name()"> Type B </xsl:when> <xsl:otherwise> Same </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="typeC"> <xsl:choose> <xsl:when test="name(preceding-sibling::*[1])!= name()"> Type C </xsl:when> <xsl:otherwise> Same </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> Thanks in advance. -----Original Message----- From: Michael Kay To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Sent: 4/27/01 10:19 AM Subject: RE: Sorting & Grouping > I appreciate your help. I read in documentation that AXIS refers to > document order and not sorted order. > > I used following xsl and it did't work. > <xsl:when > test="self::node()[name(preceding-sibling::*)!= name()]"> That predicate is true if the first preceding sibling has a different name. This means, first in document order. To test whether the last preceding sibling (ie. the immediately preceding sibling) has a different name, write test="self::node()[name(preceding-sibling::*[1])!= name()]"> or equivalently: test="name(preceding-sibling::*[1])!= name()"> Mike Kay Software AG XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








