xsl-list
[Top] [All Lists]

Re: Exclusions in XPATH

2002-11-21 08:30:16

Question 1: Can I get both attribute-names and element-names more easily in
the select or does it have to be like I have it above ?

it's hard to answer that without knowing what your criterion for
selection was intended to be.
the select expression you had was

select="./*[1]//*[not(*)]|./*[1]//@*[not(*)]">   

a leading ./ never does anything, and attributes never have element
 children so that can be simplified to

select="*[1]//*[not(*)]|*[1]//@*">      

which selects all the attributes and leaf elements of descendents of the
first child of the current node.

In your posted example the *[1] isn't doing anything as there is only
one child of A, so if that is always the case, or if you want all
descendents of A not just of the first child, it can be further
simplified to

select=".//*[not(*)]|.//@*">    

How can I exclude the descendants of element F 

select="*[1]//*[not(*) and not ancestor::F]|*[1]//*[not(ancestor::F)]/@*">      

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>