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

First positional grouping

Subject: First positional grouping
From: "I-Lin Kuo" <ikuoikuo@xxxxxxxxxxx>
Date: Wed, 07 May 2003 17:13:19 +0000
positional grouping
This is my first attempt at positional grouping and I'm almost there.
I'd like to transform


<!-- source.xml --> <root> <var VGID="AA" label="Families"/> <var label="Fathers"/> <var label="Mothers"/> <var VGID="AB" label="Relatives"/> <var label="Inlaws/> </root>

into
<!-- desiredResult.xml -->
<varList VGID="AA" label="Families"/>
	<var label="Fathers"/>
	<var label="Mothers"/>
</varList>
<varList VGID="AB" label="Relatives"/>
	<var label="Inlaws/>
</varList>

by promoting all <vars> with a @VGID. I'm following the example at
http://www.dpawson.co.uk/xsl/sect2/N4486.html#d4085e229
Using the following style sheet,

<!-- myStyleSheet.xsl -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="root">
	<root>
		<xsl:for-each select="var[@VGID]">
			<varList>
				<xsl:apply-templates select="@*"/>
				<xsl:for-each select="following-sibling::var[
					  count(preceding-sibling::var[@VGID][1] | current()) = 1]">
					<xsl:copy-of select="."/>
				</xsl:for-each>
			</varList>
		</xsl:for-each>
	</root>
</xsl:template>

<xsl:template match="@*|node()" priority="-1">
	<xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
</xsl:template>

</xsl:stylesheet>


I get this result: <!-- ActualResult.xml --> <root> <varList VGID="AA" label="Families"> <var label="Fathers" /> <var label="Mothers" /> <var VGID="AB" label="Relatives" /> </varList> <varList VGID="AB" label="Relatives"> <var label="Inlaws" /> </varList> </root>

which has an extra third node under the first <varList>.
Can someone help me get rid of the extra node? It should
be a matter of just amending the XPATH in the inner for-each.




I-Lin Kuo, Ann Arbor, MI Macromedia Certified ColdFusion 5.0 Advanced Developer Sun Certified Java 2 Programmer Ann Arbor Java Users Group (http://www.aajug.org)

_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE* http://join.msn.com/?page=features/virus



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.