Subject: RE: sub-tree filtering proposals

From: "Michael Walton" <[email-masked]>
Date: Fri, 4 Jun 2004 09:32:56 +0200

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:[email-masked]

--
to unsubscribe send a message to [email-masked] with
the word 'unsubscribe' in a single line as the message text body.
archive: <http://ops.ietf.org/lists/netconf/>

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Fri, 4 Jun 2004 09:41:10 +0200

> found one possible answer to Juergen's question:

[...]
 
> ... but that seems inefficient.

Thanks. I knew this must be possible to do somehow.

/js

-- 
Juergen Schoenwaelder		    International University Bremen
<http://www.eecs.iu-bremen.de/>	    P.O. Box 750 561, 28725 Bremen, Germany

---

From: Steve Berl <[email-masked]>
Date: Tue, 08 Jun 2004 09:04:32 -0700

Does it bother anyone else that the 1 filter expression is actually doing 2 things? 

First, it identifies the root of a tree of XML elements in the document and second it tells which subelements of those elements are to be returned. Aren't these 2 distinct functions that should better be represented by 2 separate expressions?

-steve

---

From: Juergen Schoenwaelder <[email-masked]>
Date: Tue, 8 Jun 2004 20:31:02 +0200

On Tue, Jun 08, 2004 at 09:04:32AM -0700, Steve Berl wrote:

> First, it identifies the root of a tree of XML elements in the document 
> and second it tells which subelements of those elements are to be returned. 
> Aren't these 2 distinct functions that should better be represented by 2 
> separate expressions?

An XPATH expression always identifies a nodeset (in XML speak) and the
examples I showed are AFAIK valid XPATH expressions. You can match
against element names, element contents and attribute contents with the
restricted subset I have proposed. Full XPATH allows you to do much more 
fancy selection of nodesets. But at the end, it all boils down to
selecting nodeset when using XPATH, so I fail to understand your
concern.

/js

---

From: [email-masked]
Date: Tue, 08 Jun 2004 14:50:48 -0700 (PDT)

> selecting nodeset when using XPATH, so I fail to understand your

Just a guess, but perhaps the idea is to do this the same way xs:keyref
and xs:unique work in XML schema, that is, there's both an xs:selector
and an xs:field XPath. I've never found the field/selector split
to be particularly useful myself, but YMMV.

				Ned