Re: [xsl] How to do for-each on nodeset returned by key() function

Subject: Re: [xsl] How to do for-each on nodeset returned by key() function
From: Joerg Heinicke <joerg.heinicke@xxxxxx>
Date: Mon, 23 Sep 2002 22:52:31 +0200
Hello Soumen,

the most obvious mistake is the use of ' twice (for for-each and key()). Change one of them to ":

<xsl:for-each select="key('nodeInfoMap', @name)">

Regards,

Joerg

SoumenS@xxxxxxxxx wrote:
Hi,

I have a declaration like this:

<xsl:key name = "nodeInfoMap" match= "//nodeInfo" use = "name"/>

Now when I do key('nodeInfoMap', @name) at some context, more than one nodes
are returned. i.e.

count(key('nodeInfoMap', @name) ) > 1

In other words there are more than one nodeInfo with same name but other
children/text() could
be different. Now, I wish to do a for-each loop over the nodes. I tried


<xsl:for-each select='key('nodeInfoMap', @name)'> -- DID NOT WORK
<xsl:for-each select='key('nodeInfoMap', @name)//nodeInfo'> -- DID NOT WORK

How would I iterate over the nodes returned by key function? The XML
document
in brief is given below. Basically I am trying to select a nodeInfo which

1. matches name
2. matches some other criteria

I know I can have other maps but I am interested to know how may
I iterate over nodeset returned by key().

Thanks,
Soumen.

<?xml version="1.0" encoding="iso-8859-1"?>
<snmp-metadata>
....
....
<nodeInfo>
<name>snmpOutGetRequests</name>
<oid>1.3.6.1.2.1.11.25</oid>
<full-path>iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).snmp(11).snmpOu
tGetRequests(25)</full-path>
<module>SNMPv2-MIB</module>
<parent>snmp</parent>
<prev-sibling>snmpOutGenErrs</prev-sibling>
<next-sibling>snmpOutGetNexts</next-sibling>
<type>OBJECT-TYPE</type>
<numerical-syntax>SNMP_SYNTAX_CNTR32</numerical-syntax>
<base-syntax>Counter32</base-syntax>
<composed-syntax>Counter32</composed-syntax>
<status>obsolete</status>
<max-access>read-only</max-access>
<description><![CDATA[
The total number of SNMP Get-Request PDUs whichhave been generated by the
SNMP protocol entity. ]]></description>
</nodeInfo>


<nodeInfo>
<name>snmpOutGetNexts</name>
<oid>1.3.6.1.2.1.11.26</oid>
<full-path>iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).snmp(11).snmpOu
tGetNexts(26)</full-path>
<module>SNMPv2-MIB</module>
<parent>snmp</parent>
<prev-sibling>snmpOutGetRequests</prev-sibling>
<next-sibling>snmpOutSetRequests</next-sibling>
<type>OBJECT-TYPE</type>
<numerical-syntax>SNMP_SYNTAX_CNTR32</numerical-syntax>
<base-syntax>Counter32</base-syntax>
<composed-syntax>Counter32</composed-syntax>
<status>obsolete</status>
<max-access>read-only</max-access>
<description><![CDATA[
The total number of SNMP Get-Next PDUs which havebeen generated by the SNMP
protocol entity. ]]></description>
</nodeInfo>
.....
.....
</snmp-metadata>


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread