RE: [xsl] Efficient recursive grouping in XSLT 1.0?

Subject: RE: [xsl] Efficient recursive grouping in XSLT 1.0?
From: "Ian Young" <I.M.Young@xxxxxxxxxx>
Date: Sat, 20 Mar 2004 10:38:58 -0000
Hi Andreas,

# Just out of curiosity: have you thought about doing the transformation
# in one step using multiple keys to achieve the grouping?
# 
# Some keys like:
# 
# <xsl:key name="by-depth-and-name" match="*"
#     use="concat(count(ancestor::*),' ',name())" />
# <xsl:key name="by-depth-parent-and-name" match="*"
#     use="concat(count(ancestor::*),' ',name(parent::*),' ',name())/>

Interesting. Though I'm not sure I've quite understood how this is 
supposed to work. The keys are grouped only on depth, element name and 
parent's name. Certainly, the key could be extended to include any given 
number of ancestors, but if the structures are 15 deep, this is not going 
to fly! That's what I was talking about when I said that I couldn't see 
how Muenchian grouping could be used here.
For example, with your stylesheet as posted, this input:

<root>
  <a1>
    <a2>
      <a3/>
    </a2>
  </a1>
  <b1>
    <a2>
      <a3/>
    </a2>
  </b1>
</root>

would yield:

<root ct="1">
  <a1 ct="1">
    <a2 ct="1">
      <a3 ct="2"/>
    </a2>
  </a1>
  <b1 ct="1">
    <a2 ct="1"/>
  </b1>
</root>

rather than the desired:

<root ct="1">
  <a1 ct="1">
    <a2 ct="1">
      <a3 ct="1"/>
    </a2>
  </a1>
  <b1 ct="1">
    <a2 ct="1">
      <a3 ct="1"/>
    </a2>
  </b1>
</root>

Cheers,

Ian.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread