By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,838 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,838 IT Pros & Developers. It's quick & easy.

How to find a matching element in xml with xsl

P: n/a
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>
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.