[xsl] extracting all elem names of an attribute

Subject: [xsl] extracting all elem names of an attribute
From: Saverio Perugini <sperugin@xxxxxxxxxxxxxxxx>
Date: Fri, 23 Jan 2004 02:04:03 -0500 (EST)
Hello,

How best is the following text extracted
from the following xml, possibly using keys
or some other xslt constructs?

====
size: small, medium, large
crust: thin, pan
topping: olives, pepperoni, peppers
====

<db>
   <large category="size">
      <thin category="crust">
         <olives category="topping/>
         <pepperoni category="topping/>
      </thin>
      <pan category="crust">
         <pepperoni category="topping/>
      </pan>
   </large>
   <medium category="size">
      <pan category="crust">
         <pepperoni category="topping/>
         <olives category="topping/>
         <peppers category="topping/>
      </pan>
   </medium>
   <small category="size">
      <thin category="crust">
         <olives category="topping/>
         <pepperoni category="topping/>
         <peepers category="topping/>
      </thin>
      <pan category="crust">
         <pepperoni category="topping/>
         <olives category="topping/>
         <peepers category="topping/>
      </pan>
   </small>
</db>

The basic approach involves:
  
   - using keys to get a unique list of possible values for the @category attribute
   - iterating over these values 
        - printing each followed by a colon
        - getting a unique list of all xml element names which contain this particular attribute value
             - iterating over these values
                  printing each
                  printing an endline

Many thanks and Best regards,
Saverio

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


Current Thread