I have an xml document that contains set definitions and element definitions. Sample XML:
<!-- a set definition -->
<a name="SET.1" mnemonic="NAME_SET" ... />
<!-- an element definition -->
<a name="NAME_SET.1" mnemonic="Element1" .../>
I have no control over the xml that is coming in. The only way to tell the difference between a set definition and an element definition is by the value of the name
attribute. In a set definition, it will start with "SET"; in an element definition, it will start with the value of the set's mnemonic attribute.
I'd like to do use XSLT to sort the file by set and then by elements within the set. Meaning:
<!-- a set definition -->
<a name="SET.1" mnemonic="ANIMAL_SET" ... />
<!-- an element definition -->
<a name="ANIMAL_SET.1" mnemonic="Mouse" .../>
... all the elements in ANIMAL_SET
<!-- a set definition -->
<a name="SET.2" mnemonic="VEHICLE_SET" ... />
<!-- an element definition -->
<a name="VEHICLE_SET.1" mnemonic="Car" .../>
... all the elements in VEHICLE_SET
I believe that to do this, I'd use <xsl:for-each>
, but I'm not sure how. Any ideas?
No comments:
Post a Comment