[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Sorting & Grouping

Subject: RE: Sorting & Grouping
From: Satish Patil <Satish.Patil@xxxxxxx>
Date: Fri, 27 Apr 2001 10:40:51 -0400
satish patil
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.