[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2008-10-20 21:37 +0200, Giacomo wrote:
XPath doesn't copy elements, it only addresses or queries them.
If you had such an XPath expression, how would you use it?
I think you may be misunderstanding the role of XPath to talk about a tree. For example, I can use XPath to *find* all of the elements at any depth not including C and D:
<xsl:output method="text"/>
But now what are you going to do with those nodes once you've addressed them?
In XSLT if you try and use <xsl:copy-of/> that is defined to copy the *entire* structure of *each* element, getting descendent elements twice.
So, you can use XPath to *find* information, but it has no role in copying information, only whatever specification might be using XPath to find information.
I hope this helps.
. . . . . . . . . Ken
Re: [xsl] Copy excluding some children
Subject: Re: [xsl] Copy excluding some children From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 20 Oct 2008 15:59:41 -0400 |
At 2008-10-20 21:37 +0200, Giacomo wrote:
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?
XPath doesn't copy elements, it only addresses or queries them.
If you had such an XPath expression, how would you use it?
I think you may be misunderstanding the role of XPath to talk about a tree. For example, I can use XPath to *find* all of the elements at any depth not including C and D:
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:output method="text"/>
<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>
But now what are you going to do with those nodes once you've addressed them?
In XSLT if you try and use <xsl:copy-of/> that is defined to copy the *entire* structure of *each* element, getting descendent elements twice.
So, you can use XPath to *find* information, but it has no role in copying information, only whatever specification might be using XPath to find information.
I hope this helps.
. . . . . . . . . Ken
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 |