M
mikael petterson
Hi,
I have the following xml-file and need extract the following:
.............
- <enum name="TxDeviceGroup_BbBusState">
<description></description>
- <enumMember name="MASTER_LOADSHARING">
<value>0</value>
</enumMember>
- <enumMember name="MASTER_NO_LOADSHARING">
<value>1</value>
</enumMember>
- <enumMember name="SLAVE">
<value>2</value>
</enumMember>
- <enumMember name="BUS_DISABLED">
<value>3</value>
</enumMember>
</enum>
.....................................
Here is the xsl for retrieving minEnum:
=============================
<xsl:template name="enumMin">
<xslaram name="str"/>
<!-- Find the enum with the same name as $str ( In this case:
TxDeviceGroup_BbBusState). Find the enumMember
with child <value> that is equal to 0. Then get name attr of element
enumMember.
-->
<xsl:if test="/models/mim/$str/enumMember/value='0'">
<!-- Now get name attr of element enumMember -->
<xsl:value-of select="../@name"/>
</xsl:if>
</xsl:template>
Question 1:
Is this the fastest way to get the attribute value?
Question 2:
When I have a made the following test;
<xsl:if test="/models/mim/$str/enumMember/value='0'">
Will the current node be (using xpath syntax ". ") <value>-tag ? So to
access the parent <enumMember> and it's attribute it is correct to use
.../@name??
//Regards,
//Mikael
I have the following xml-file and need extract the following:
.............
- <enum name="TxDeviceGroup_BbBusState">
<description></description>
- <enumMember name="MASTER_LOADSHARING">
<value>0</value>
</enumMember>
- <enumMember name="MASTER_NO_LOADSHARING">
<value>1</value>
</enumMember>
- <enumMember name="SLAVE">
<value>2</value>
</enumMember>
- <enumMember name="BUS_DISABLED">
<value>3</value>
</enumMember>
</enum>
.....................................
Here is the xsl for retrieving minEnum:
=============================
<xsl:template name="enumMin">
<xslaram name="str"/>
<!-- Find the enum with the same name as $str ( In this case:
TxDeviceGroup_BbBusState). Find the enumMember
with child <value> that is equal to 0. Then get name attr of element
enumMember.
-->
<xsl:if test="/models/mim/$str/enumMember/value='0'">
<!-- Now get name attr of element enumMember -->
<xsl:value-of select="../@name"/>
</xsl:if>
</xsl:template>
Question 1:
Is this the fastest way to get the attribute value?
Question 2:
When I have a made the following test;
<xsl:if test="/models/mim/$str/enumMember/value='0'">
Will the current node be (using xpath syntax ". ") <value>-tag ? So to
access the parent <enumMember> and it's attribute it is correct to use
.../@name??
//Regards,
//Mikael