[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XML Encoding of XPath: Examples

  • From: Wayne Steele <xmlmaster@h...>
  • To: vdv@d..., xml-dev@l...
  • Date: Thu, 15 Mar 2001 11:16:17 -0800

xpath examples
>From: Eric van der Vlist <vdv@d...>
>To: xml-dev@l...
>Subject: Re: XML Encoding of XPath: Examples
>Date: Thu, 15 Mar 2001 17:58:32 +0100
>
>Wayne Steele wrote:
> >
> > I propose an optional XML Encoding for XPath expressions.
> > I just posted a DTD; here's some usage examples to help clarify things.
> >
> > Questions/Comments/Errata welcome.
>
>It's a neat proposal!

Thank you.

>I have some questions:
>
>Having used HP polish notation a lot in my early days, I would have
>thought of an XPath expression as a stack and would have embedded the
>location steps instead of keeping them at the same level...

That was my original thought.
Modeling Location Steps as functions, and using a prefix notation.
I ended up with something like
   child::foo/attribute::bar
looking like
   <attribute name="bar">
      <child name="foo">
         <contextNode />
      </child>
   </attribute>

I didn't like the need to specify where the initial context is resolved, 
somewhere deeply nested in the XML.

I couldn't think of a clean way to handle predicates.

I also noticed that the 'child' node above would never have any siblings, so 
nesting didn't seem to really express the logical structure of XPath.

XPath defines a Location Path expression as a _series_ of location steps.
Each one operates on the output of the previous one.

A flat sequence of elements seems like a good way to express that, as well 
as keeping the 'look' of XPath.

It also lets me reserve child elements for predicates, without having to 
create a <predicate> element to muddy the waters.


>Can you give examples of location steps within conditions ?
>(such as child::chapter[section/title="XML Encoding of XPath"])

I think you've got me there.
The examples I gave all have (at most) a single-step path expression inside 
a predicate.

Perhaps I need a wrapper element for an XPath Location Path.
Then I could do:
<location-path>
   <child name="chapter">
     <eq>
        <location-path>
           <child name="section"/>
           <child name="title"/>
        </location-path>
        <literal>XML Encoding of XPath</literal>
      </eq>
   </child>
</location-path>

This would also give you something to use for the documentElement of an 
XPath expression, so they can be always well-formed.


>Wouldn't it be a good idea to extend it to encode XPointer ?

Yes.
One thing at a time.

>Eric
>
> > -Wayne Steele
> >

Thanks for your comments.

I dare anyone to give me an XPath expression I cannot encode this way.
Or alternately, an XML Encoded XPath document that doesn't have an 
unambiguous XPath syntax.

-Wayne Steele
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.