Subject: Re: [xsl] Copy excluding some children From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 20 Oct 2008 15:59:41 -0400 |
Is there a way to copy an element excluding some children, at any depth, using *only* an XPath 2.0 expression without using templates to exclude such elements?
T:\ftemp>type giacomo.xml <A> <B>The pen is <C>not</C> on the table</B> <D>...</D> </A> T:\ftemp>type giacomo.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="/"> <xsl:for-each select="//* except ( //C | //D )"> Found: <xsl:value-of select="name(.)"/> </xsl:for-each> </xsl:template>
</xsl:stylesheet> T:\ftemp>xslt2 giacomo.xml giacomo.xsl con
Found: A Found: B T:\ftemp>
For example, given:
<A> <B>The pen is <C>not</C> on the table</B> <D>...</D> </A>
I want to copy A without C and D obtaining:
<A> <B>The pen is on the table</B> </A>
Thanks, Giacomo.
-- Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Copy excluding some child, Michael Kay | Thread | Re: [xsl] Identifier attribute (was, Rowan Sylvester-Brad |
RE: [xsl] Copy excluding some child, Michael Kay | Date | Re: [xsl] Identifier attribute (was, Rowan Sylvester-Brad |
Month |