Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Help me with XPATH expression

From: Peter Flynn <peter.nosp@-.--------.-->
To: NULL
Date: 10/1/2006 10:39:00 PM

ajkadri@g... wrote:
> Hi folks,
> 
> I am new to XML. I came across the following location path expressions:
> 
> (i)   /*/*
> 
> (ii)  /quotelist/quotation
> 
> can anyone explain me the nodeset for the above two path expressions

Assuming this is XPath, then

(i) means "any element which is a child of [any] root element".
     In your sample document, it will return a nodeset of three
     quotation elements.

(ii) means "all quotation elements which are children of the
     quotelist root element". The effect on your sample document
     is identical to (i).

According to whatever DTD or schema you use, there may of course be
other element types which are permitted within quotelist. These will
be included in the nodeset by (i) but not by (ii).

Equally, your application may allow other element types to be the
root element of different subtypes of document. In that case, (i)
may be more appropriate than (ii) in some circumstances. For example,
if you output a document consisting of a single quotation, eg:

<quotation style="wise" id="q1">
   <text> Expect nothing; be ready for everything.  </text>
   <source> Samurai Chant </source>
</quotation>

then (i) will return a nodeset consisting of a text element and a source 
element, but (ii) will return an empty nodeset.

As a matter of style and efficiency, you should avoid using leading and
trailing spaces in element types containing PCDATA or mixed content, in
case later processing systems are unaware of it (the source above, for
example, is NOT equal to "Samurai Chant" but " Samurai Chant " with the
extra spaces.

///Peter
-- 
XML FAQ: http://xml.silmaril.ie/

> relating to the following XML document:
> 
> <quotelist>
>     <quotation style="wise" id="q1">
>           <text> Expect nothing; be ready for everything.  </text>
>           <source> Samurai Chant </source>
>     </quotation>
> 
>    <quotation style="political" id="q2">
>           <text> If one morning I walked on top of the water across the
> Potomac
>           River, teh headline that afternoon would read "President
> can't Swim".</text>
>           <source> XYZ </source>
>     </quotation>
>    <!-- This is a comment -->
>    <quotation style="silly" id="q3">
>           <text> What if the hokey-pokey IS what it's all about?
> </text>
> 
>     </quotation>
> 
>  </quotelist>
> 
> Thanks in anticipation.
> 
> Regards,
> Asrar
> 


transparent
Print
Mail
Like It
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