Altova Mailing List Archives

RE: [xsl] Applying Attributes with Grouping Method

From: "Michael Kay" <mike@------------>
Date: 3/21/2007 5:13:00 PM
> I'm having a problem with grouping using attributes and I'm 
> tired of banging my head against the wall.  I'm using Saxon V8.5.

If you're using Saxon 8.x (the latest release is Saxon 8.9, by the way) then
you don't need Muenchian grouping, you can use xsl:for-each-group, which is
much simpler.
> I've found part of my answer to my original grouping question 
> in the FAQ section and got that to work, however, I'm still 
> not getting my desired output.

No-one can tell you where you went wrong unless you show us your code.

> My desired output is this:
> <report>
> 	<item part="W1123" quantity="3" val="Part_A" name="P21,P22,P23"
> />
> 	<item part="W1144" quantity="1" val="Part_B" name="J31" />
> 	<item part="W1145" quantity="1" val="Part_C" name="J32" 
> /> </report>


<xsl:for-each-group select="conn" group-by="part">
  <item part="{@part} val="{property/@val}
     name="{string-join(current-group()/@name, ',')}"/>

Michael Kay

> My original question was with grouping, specifically with the 
> name attribute, and I think I kind of understand grouping 
> now, thanks to the link on "Grouping Using the Muenchian Method". 
> My problem is bringing the name attribute into my existing
> reportdetails.   Currently I'm generating this:
> <report>
> 	<item part="W1123" quantity="3" val="Part_A" />
> 	<item part="W1144" quantity="1" val="Part_B" />
> 	<item part="W1145" quantity="1" val="Part_C" /> </report>
> Now, I can get the name attributes grouped using the 
> Muenchian Method in a separate XSL style sheet.
> My problem is when I start applying attributes.  Obviously 
> the attribute value is not behaving like I thought it would.
> Could someone provide insight on how to tackle this problem?
> Here is a small sample of the xml data:
> <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>
> Thank you,
> Karl


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.