Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: A question about XPath filters (predicates)

From: Altu <altu59@-----.--->
To: NULL
Date: 10/6/2007 3:34:00 PM

Hi Peter,

Thanks for the reply.

The thing that was confusing me was that why would we insert a
predicate that starts with / or // in a specifiec location in the
XPath query. Looks like _generally_ they can be anywhere in the
query and yet we will get the same result.

So

//a/b/*/c//d[/a/b/d][/a//b/g][/a/b//g] is equal to
//a[/a/b/d]/b[/a//b/g]/*/c//d[/a/b//g] is equal to
//a[/a/b/d][/a//b/g][/a/b//g]/b/*/c//d

with possible performance differences.

Regards,
Al


On Oct 7, 4:58 am, Peter Flynn <peter.n...@m.silmaril.ie> wrote:
> Altu wrote:
> > Hi all,
>
> > What does something like [/a/b] mean
>
> It creates a dependency for the preceding object reference.
> In this case it specifies that there must exist an element b which is a
> child of the root element a. This condition will be applied to whatever
> precedes the [/a/b] in the statement
>
> > in an XPath query like /c/d[/a/b] ?
>
> This will return or process a child element d of the root element c
> provided that a child element b exists of the root element a. As an XML
> document can only have one root element, this condition can never be
> satisfied, so the statement will always return null or false.
>
> > If I am not wrong, /c/d[./a/b] means return all d elements that their
> > parent is c and their grand parent is the root element and have a
> > child that is a and their a child has a child b.
>
> That's not the query you posted at the start of your message.
> The period introduces a change in scope, so that ./a/b now refers
> to the structure you describe correctly.
>
> > But I don't know when
> > we don't use an expression that starts with ./ or .// in a predicate
> > and instead use an epxression that starts with / or // what it would
> > mean.
>
> Exactly the same as you would when making a directory reference in a
> typed command, eg
>     cd /var/www/html
>     rm -rf /home/peter
> will delete all my personal files irrespective of my current directory.
>     cd /var/www/html
>     rm -rf ./home/peter
> will delete any files in /var/www/html/home/peter
>
> > Does /c/d[/a], for example, mean return all d elements that have a
> > parent (c with a parent root) only if the root has a child a?
>
> Yes, which is an impossibility for the reason already given.
>
> ///Peter




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent