|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Exclusions in XPATH
Hi Robin, > XSL: > <xsl:template match="A"> > <xsl:for-each > select="./*[1]//*[not(*)]|./*[1]//@*[not(*)]"> > <xsl:value-of select="name()"/> > <xsl:if test="position()!=last()">;</xsl:if> > > </xsl:for-each> > <xsl:apply-templates/> > </xsl:template> > > 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 ? You can probably simplify the expression you're using to select the elements and attributes to: .//*[not(*)] | .//@* I say probably because (a) your path only looks at the descendants of the first child of the <A> element, whereas the above looks at all descendants of the <A> element and (b) your path wouldn't pick the <B> element if it only held text, whereas mine would. > If I only know the element-names A and F > > Question 2: How can I exclude the descendants of element F from the > select ? Output would then be C;E;W. I've tried various combinations > but either end up with all-or-nothing. I think that the easiest way would be to add a filter to the expression to only select those nodes that do not have the <F> element as an ancestor: (.//*[not(*)] | .//@*)[not(ancestor::F)] Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








