![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries >Thread Prev - Re: A question about XPath filters (predicates) >Thread Next - Re: A question about XPath filters (predicates) Re: A question about XPath filters (predicates)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 | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||
|
