xsl-list
[Top] [All Lists]

RE: [xsl] Applying Attributes with Grouping Method

2007-03-21 10:13:22

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>

Try

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

Michael Kay
http://www.saxonica.com/



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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>