[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: sub-tree filtering proposals
Hi
I've been following netconf for a couple of weeks now. Hopefully I can
add a bit of noise to a quiet list.
For now - I experimented a little with XPath expressions in PyXML and
found one possible answer to Juergen's question:
>> C.6) Specific elements from a specific <user> entry
>>
>> Request:
>>
>> <rpc message-id="101" xmlns="netconf-uri">
>> <get>
>> <data>
>> <filter filter-type="subtree">
>> <users xmlns="http://example.com/schema-1">
>> <user>
>> <name>fred</name>
>> <type/>
>> <full-name/>
>> </user>
>> </users>
>> </filter>
>> </data>
>> </get>
>> </rpc>
>>
>> Reply:
>>
>> <rpc-reply message-id="101" xmlns="netconf-uri">
>> <data>
>> <users xmlns="http://example.com/schema-1">
>> <user>
>> <name>fred</name>
>> <type>admin</type>
>> <full-name>Fred Flintstone</full-name>
>> </user>
>> </users>
>> </data>
>> </rpc-reply>
>>
>> Notes:
>>
>> - This filter contains two containment nodes (users, user),
>> one content match node (name), and two selector nodes
>> (type, full-name).
>> - All instances of the 'type' and 'full-name' elements in
>> the same siibling set containing 'name', for which the value
>> of 'name' equals "fred", are selected in the filter output.
>> The 'company-info' element is not included because the
>> sibling set contains selection nodes.
>
>The XPATH expression "//users/user[name="fred"]/name" will just return
>the name element - not sure how one can select multiple elements with
>XPATH in this case (but I am an XPATH beginner - perhaps someone out
>there knows the answer).
>
An expression that returns name, type and full-name looks like this:
//users/user[name="fred"]/*[name()="name" or name()="type" or
name()="full-name]
... which is somewhat ugly, or you could use the "pipeline" operator as
suggested by Juergen:
//users/user[name="fred"]/name | //users/user[name="fred"]/type |
//users/user[name="fred"]/full-name
... but that seems inefficient.
Michael Walton
Flextronics South Africa
C301 Warehouse Building
Black River Park, Fir Street
Observatory, 7925, South Africa
+27 21 442 1240 Main
+27 21 442 1253 Direct
+27 21 442 1264 Fax
+27 83 233 1226 Mobile
mailto:michael.walton@za.flextronics.com
--
to unsubscribe send a message to netconf-request@ops.ietf.org with
the word 'unsubscribe' in a single line as the message text body.
archive: <http://ops.ietf.org/lists/netconf/>