xpath filtering

Sometimes the data element that qualifies the information you want is at a lower level in the data hierarchy than the information you need.

For example, if you want to return a list of interfaces that are bound to a CoS-to-CoS mutation QoS map, the element to be used for the selection criteria (<cos-mutation>name</cos-mutation>) resides at a lower level in the hierarchy than the information to be retrieved (the interface name), as shown in the following representation of the QoS map structure. In such cases, you must use an xpath filter and not a subtree filter.

| +--rw ethernet [name]
+--rw name						interface-type
.
.
.
+--rw qos:qos
+--rw qos:default-cos?			int32
+--rw qos:cos-mutation?			map-name-type
+--rw qos:cos-traffic-class?	map-name-type
+--rw qos:dscp-mutation?		map-name-type

The following example returns the interface names to which the CoS-to-CoS mutation QoS map named “test” is bound. In this case, the map named “test” is bound to interfaces 2/5 and 2/6. The <filter> element tag specifies that the filter type is xpath and also specifies the data path and selection criteria.

<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="205">
	<get-config>
		<source>
			<running></running>
		</source>
			<filter type="xpath" select="/interface/ethernet/qos[cos-mutation='test']"></filter>
	</get-config>
</rpc>

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="205">
	<data>
		<interface xmlns="urn:brocade.com:mgmt:brocade-interface">
			<ethernet>
				<name>0/5</name>
				<qos xmlns="urn:brocade.com:mgmt:brocade-qos">
					<default-cos>0</default-cos>
					<cos-mutation>test</cos-mutation>
				</qos>
			</ethernet>
			<ethernet>
				<name>0/6</name>
				<qos xmlns="urn:brocade.com:mgmt:brocade-qos">
					<default-cos>0</default-cos>
					<cos-mutation>test</cos-mutation>
				</qos>
			</ethernet>
		</interface>
	</data>
</rpc-reply>