| Francis Norton
Q expansion:
I want to cross reference an item with corresponding state. Each
value corresponds to a state within a character (so in the above
example a chicken has two legs, and a worm has none).
<taxa>
<character-list>
<character number="1">
<state number="1">no legs</state>
<state number="2">2 legs</state>
<state number="3">4 legs</state>
</character>
</character-list>
<item id="1">
<item-name>Chicken</item-name>
<attribute-list>
<attribute character="1"><value>2</value></attribute>
</attribute-list>
</item>
<item id="2">
<item-name>Worm</item-name>
<attribute-list>
<attribute
character="1"><value>1</value></attribute>
</attribute-list>
</item>
</taxa>
<?xml version="1.0"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Tranform"
version="1.0">
<xsl:template match="/">
<result>
<xsl:apply-templates select="//item"/>
</result>
</xsl:template>
<xsl:template match="item">
<expanded-item name="{item-name}">
<xsl:for-each select="attribute-list/attribute">
<xsl:for-each
select="//character[@number=current()/@character]
/state[@number=current()/value]">
<property>
<xsl:value-of select="." />
</property>
</xsl:for-each>
</xsl:for-each>
</expanded-item>
</xsl:template>
</xsl:stylesheet>
|