Subject: RE: [xsl] Sorting & Grouping From: Satish Patil <Satish.Patil@xxxxxxx> Date: Fri, 27 Apr 2001 10:40:51 -0400 |
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: [xsl] 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Sorting & Grouping, Michael Kay | Thread | [xsl] ordering and iteration proble, Mark Nahabedian |
Re: [xsl] xsl] XSL and XMLSchema, Karim Barkati | Date | RE: [xsl] xsl] XSL and XMLSchema, Michael Kay |
Month |