Subject: Re: [xsl] Are these equivalent XPath expressions for determining that there are no duplicates in a list of items? From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Thu, 1 Nov 2012 06:17:24 -0700 |
> Here is an XPath 2.0 expression to answer that question (thanks to Dimitre): > > empty(Websites/*[index-of(../*,.)[2]]) > > Here is an XPath 1.0 expression to answer that question: > > not(//Websites/*[. = preceding-sibling::*]) > > Are there any situations where those two XPath expressions differ in their answer? I think that two expressions are "equivalent" if their evaluation produces the same result on any XML document. These *would be* equivalent, especially if "//" is removed from the second expression. As we know well, these are generally different: Websites and //Websites Cheers, Dimitre On Thu, Nov 1, 2012 at 6:01 AM, Costello, Roger L. <costello@xxxxxxxxx> wrote: > Hi Folks, > > Are there no duplicate websites in this list: > > <Websites> > <Website id="Amazon"> http://www.amazon.com </Website> > <Website id="Apple"> http://www.apple.com </Website> > <Website id="Ebay"> http://www.ebay.com </Website> > <Website id="Google"> http://www.google.com </Website> > <Website id="Microsoft"> http://www.microsoft.com </Website> > <Website id="VirginAtlantic"> http://www.virgin-atlantic.com </Website> > </Websites> > > Here is an XPath 2.0 expression to answer that question (thanks to Dimitre): > > empty(Websites/*[index-of(../*,.)[2]]) > > Here is an XPath 1.0 expression to answer that question: > > not(//Websites/*[. = preceding-sibling::*]) > > Are there any situations where those two XPath expressions differ in their answer? > > /Roger > -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- To avoid situations in which you might make mistakes may be the biggest mistake of all ------------------------------------ Quality means doing it right when no one is looking. ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play ------------------------------------- Facts do not cease to exist because they are ignored. ------------------------------------- Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :) ------------------------------------- I finally figured out the only reason to be alive is to enjoy it.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Are these equivalent XPat, David Carlisle | Thread | Re: [xsl] Are these equivalent XPat, Mukul Gandhi |
Re: [xsl] Are these equivalent XPat, David Carlisle | Date | Re: [xsl] Are these equivalent XPat, Mukul Gandhi |
Month |