Re: [xsl] best-technique for selective group and merge?

Subject: Re: [xsl] best-technique for selective group and merge?
From: "James A. Robinson" <jimr@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 02 Mar 2004 08:43:45 -0800
On Tue, 02 Mar 2004 08:31:01 -0800 I wrote:
< 
< Given input of the form
< 
<   <?xml version="1.0"?>
<   <config_datastore>
<     <feature name="a">
<       <config id="1">
<         <param id="x">x</param>
<       </config>
<     </feature>
< ...

Ugh, my apologies. I didn't send a complete example which shows the
problem I'm trying to solve. The feature can contain multiple configs,
each of which I want to merge across features:

  <?xml version="1.0"?>
  <config_datastore>
    <feature name="a">
      <config id="1">
        <param id="x">x</param>
      </config>
      <config id="2">
        <param id="xx">xx</param>
      </config>
      <config id="3">
        <param id="xxx">xxx</param>
      </config>
    </feature>
    <feature name="b">
      <config id="1">
        <param id="y">y</param>
      </config>
      <config id="2">
        <param id="yy">yy</param>
      </config>
    </feature>
    <feature name="c">
      <config id="1">
        <param id="z">z</param>
      </config>
      <config id="2">
        <param id="zz">zz</param>
      </config>
    </feature>
    <site>
      <has_feature name="a"/>
      <has_feature name="c"/>
    </site>
  </config_datastore>

I want to be able to select /config_datastore/site/* and perform selective
grouping (on feature @name) and merging (on the feature/config elements)
to return:

  <config id="1">
    <param id="x">x</param>
    <param id="z">z</param>
  </config>
  <config id="2">
    <param id="xx">x</param>
    <param id="zz">z</param>
  </config>
  <config id="3">
    <param id="xxx">xxx</param>
  </config>

The tree fragment example I posted shows essentially what I have now,
I can grab the each major config set, but I then want to perform a merge.
The example I posted makes it look like I could just run

  <xsl:copy-of select="key('feature', @name)/config/*"/>

but I can't, because each config has it's own uniqueness
(id 1, id 2, id 3, etc.).

I'll go get some coffee now before I try and post again.

Jim
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       jim.robinson@xxxxxxxxxxxx
Stanford University HighWire Press      http://highwire.stanford.edu/
650-723-7294 (W) 650-725-9335 (F)   

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


Current Thread