|
Subject:
|
Matching of attribute values
|
|
Posted By:
|
gb
|
Post Date:
|
2/9/2004 11:40:35 AM
|
Hi,
I have a basic question of matching of attribute values:
If I have a document fragment:
<model>
<enum name="ABC"> <enunMember name="member1"> <value>0</value> </enumMember> <enunMember name="member2"> <value>1</value> </enumMember> </enum>
<enum name="XYZ"> <enumMember name="member5"> <value>20</value> </enumMember> <enumMember name="member7"> <value>22</value> </enumMember> </enum>
<class> <attribute name="attr1"> <datatype> <enumRef name= "ABC"> <value>20</value> </enumRef> </datatype> </attribute> </class>
</model>
---------------------------------------------------------------------------------------------------
When processing an 'attribute', I want to dump out the type information of the referenced "enum". I am struggling with the syntax to find the related "enum" from the "enumRef" name in "attribute".
I'm using the following:
<xsl:template match="enumRef"> <xsl:value-of select="@name"/> <!-- Dumps out ABC correctly -->
<xsl:apply-templates select="//enum[@name ='ABC']"> <!-- Works OK --> <xsl:apply-templates select="//enum[@name='{attribute::@name}' ]"> <!-- Does not work -->
</xsl:apply-templates> </xsl:template>
What is the correct syntax to match an element using an attribute ["name" in this case] generically?
many thanks, gb
|
|
Reply By:
|
joefawcett
|
Reply Date:
|
2/9/2004 4:25:59 PM
|
I think you needf to use current node:
<xsl:template match="enumRef">
<xsl:apply-templates select="//enum[@name = current()/@name ]"/> </xsl:template>
--
Joe
|
|
Reply By:
|
gb
|
Reply Date:
|
2/10/2004 3:12:01 AM
|
Joe,
Thanks for this.
regards, gb
|