xsl-list
[Top] [All Lists]

RE: [xsl] XPath for parent nodes, but excluding their children

2011-07-01 11:34:30
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(_at_)saxonica(_dot_)com] 
Sent: Thursday, June 30, 2011 5:25 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or 
e-mail:<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • RE: [xsl] XPath for parent nodes, but excluding their children, Joel Dubien <=