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

Re: Applying Attributes with Grouping Method

Subject: Re: Applying Attributes with Grouping Method
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 21 Mar 2007 12:48:35 GMT
Re:  Applying Attributes with Grouping Method
> I'm tired of banging my head against the wall.

Keep doing it, you get used to it eventually!

> Now, I can get the name attributes grouped using the Muenchian Method
> in

you are using saxon8 so XSLT2 so you don't need Muenchian grouping,
once I'd made your input example well formed, it's just a call to
xsl:for-each-group:

<connection>
	<conn name="P21" part="W1123">
		<property name="s_des" val="Part_A"/>
	</conn>
	<conn name="P22" part="W1123">
		<property name="s_des" val="Part_A"/>
	</conn>
	<conn name="P23" part="W1123">
		<property name="s_des" val="Part_A"/>
	</conn>
	<conn name="J31" part="W1144">
		<property name="s_des" val="Part_B"/>
	</conn>
	<conn name="J32" part="W1145">
		<property name="s_des" val="Part_C"/>
	</conn>
</connection>




<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output indent="yes"/>

  <xsl:template match="connection">
    <report>
      <xsl:for-each-group select="conn" group-by="property[@name='s_des']/@val">
	<item part="{@part}" 
	uantity="{count(current-group())}"
	val="{current-grouping-key()}"
	name="{current-group()/@name}"/> 
      </xsl:for-each-group>
    </report>
  </xsl:template>

</xsl:stylesheet>


$ saxon8 connection.xml  connection.xsl 
<?xml version="1.0" encoding="UTF-8"?>
<report>
   <item part="W1123" uantity="3" val="Part_A" name="P21 P22 P23"/>
   <item part="W1144" uantity="1" val="Part_B" name="J31"/>
   <item part="W1145" uantity="1" val="Part_C" name="J32"/>
</report>


David

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.