|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Copy excluding some children
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: -- 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
|
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








