How to find a matching element in xml with xsl

P

Petterson Mikael

Hi,

I have managed to get the name of the enum e.g. TxDeviceGroup_BbBusState
in the first part of the xml in the class element.
Now I need to find the minimum value of the enum called
TxDeviceGroup_BbBusState in the xml.
This is an operation I need to do for many enums.

I thought of doing something like this:

<xsl:call-template name="enumMin">
<xsl:with-param name="str"
select="enumRef/@name"/></xsl:call-template>

<!-- Now str have the value "TxDeviceGroup_BbBusState"
Then search the xml document for the enum, TxDeviceGroup_BbBusState
-->

<xsl:template name="enumMin">
<xsl:param name="str"/>
<xsl:if test="//enum/@name=$str">

<!-- Here i need to find the <enumMember> with <value> 0 ( or lowest)
and retrieve the
attribute name of <enumMember> -->

</xsl:if>

</xsl:template>

I appreciate all hints I could get.

//Mikael


My xml-file:
============


<class name="TxDeviceGroup">
<description>Device group for the Transmitter.
</description>
<attribute name="bbBusState">
<description>
</description>
<noNotification/>
<nonPersistent/>
<readOnly/>
<dataType>
<enumRef name="TxDeviceGroup_BbBusState">
<defaultValue>BUS_DISABLED</defaultValue>
</enumRef>
</dataType>
</attribute>

.........



<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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top