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

Re: Grouping and numbering in XSLT 2.0,

Subject: Re: Grouping and numbering in XSLT 2.0,
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Mon, 14 Nov 2005 10:04:43 +0000
itt cannon 14
> The v2.0 solution to this problem, could be nice to see. So, If someone
> of you could show me, I would appreciate that.

I don't think you need any grouping or 2.0 featuers here, you just
need to apply-templates to the <value> elements of the company cell,
then to the others in the same position:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
	<vendors>
		<xsl:apply-templates select="/vendors/cell[@name = 'Company']/value"/>
	</vendors>
</xsl:template>

<xsl:template match="cell[@name = 'Company']/value">
	<vendor>
		<cell name="Company">
			<xsl:copy-of select="."/>
		</cell>
		<xsl:variable name="pos" select="position()"/>
		<xsl:apply-templates select="/vendors/cell[@name = 'Cage']/value[$pos]"/>
		<xsl:apply-templates select="/vendors/cell[@name =
'Address']/value[$pos]"/>
	</vendor>
</xsl:template>

<xsl:template match="cell[@name = 'Cage']/value">
	<cell name="Cage">
		<xsl:copy-of select="."/>
	</cell>
</xsl:template>

<xsl:template match="cell[@name = 'Address']/value">
	<cell name="Address">
		<xsl:copy-of select="."/>
	</cell>
</xsl:template>

</xsl:stylesheet>

produces:

<?xml version="1.0" encoding="utf-8"?>
<vendors>
	<vendor>
		<cell name="Company">
			<value>AMPHENOL AEROSPACE OPERATIONS</value>
		</cell>
		<cell name="Cage">
			<value>77820</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>ITT CANNON</value>
		</cell>
		<cell name="Cage">
			<value>71468</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>SOURIAU CONNECTION TECHNOLOGY (FCI)</value>
		</cell>
		<cell name="Cage">
			<value>F0225</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>DEUTSCH ECD</value>
		</cell>
		<cell name="Cage">
			<value>11139</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>AERO ELECTRIC CONNECTOR INC</value>
		</cell>
		<cell name="Cage">
			<value>59976</value>
		</cell>
		<cell name="Address">
			<value>TORRANCE</value>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>AMPHENOL CORPORATION</value>
		</cell>
		<cell name="Cage">
			<value>74868</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
	<vendor>
		<cell name="Company">
			<value>TEC ELECTRICAL COMPONENTS LTD</value>
		</cell>
		<cell name="Cage">
			<value>K0690</value>
		</cell>
		<cell name="Address">
			<value/>
		</cell>
	</vendor>
</vendors>


cheers
andrew

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.