Subject: RE: [xsl] XPath for parent nodes, but excluding their children From: Joel Dubien <joel@xxxxxxxxxxxxxxx> Date: Fri, 1 Jul 2011 16:32:16 +0000 |
Thanks for clarifying Michael. That makes complete sense and was what I had assumed. I wanted to ensure I wasn't missing something obvious. -Joel -----Original Message----- From: Michael Kay [mailto:mike@xxxxxxxxxxxx] Sent: Thursday, June 30, 2011 5:25 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] XPath for parent nodes, but excluding their children There's a a lot of misunderstanding here. When you use an expression like //div, XPath selects the div elements only, it does not select their children or other descendants. It returns to the caller, in effect, pointers to these div elements. What happens next is up to the caller. It's quite common for the caller to process (e.g. display or copy) the whole subtree rooted at a selected element. Such behaviour can't be controlled using the XPath expression, because the XPath engine doesn't determine what the client does with the selected nodes. If you want to return to the client a node that doesn't have these children attached, you can't do this using XPath, because XPath can only select nodes as they exist in the input tree, it can't transform them into a different tree. That's XSLT territory. Michael Kay Saxonica On 30/06/2011 22:23, Joel Dubien wrote: > Hello All, > > I need some help with an XPath issue (this is for an xi:include in an XML doc, I am not using XLST to transform the XML, so I'm not sure if this is even possible). I want to retrieve all the parent nodes, but not any of the chilren nodes: > > Example: > <root> > <parent1> > <child> > </child> > </parent1> > <parent2> > <child> > <child> > </parent2> > </root> > > I want to get some xpath to grab just the parent nodes: > > Xpath to retrieve: > <parent1/> > <parent2/> > > > Does anyone know how to do this with XPath w/o using XSLT to transform the xml? > > TYIA! > > -Joel
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] RE: Flat bullets to neste, Emma Burrows | Thread | [xsl] Text() Template copy conditio, Senthilukvelaan |
[xsl] RE: Flat bullets to nested ul, Emma Burrows | Date | Re: [xsl] RE: Flat bullets to neste, Eliot Kimber |
Month |