At 2008-02-26 10:41 -0800, Michael Daniloff wrote:
What is the best approach to remove any nodes between
2 marker elements matching by their id attributes?
...
Sorry for the incomplete xml fragment, but those
bookmarks could be pretty much anywhere in hierarchy.
What did you want done with the ancestors of the ending bookmark?
An example is below using document order, but it will work with your
example only because there are no ancestors of the ending bookmark
that follow the starting bookmark. I can't guess what you want done
with those ancestors.
I hope this helps.
. . . . . . . . . . Ken
t:\ftemp>type daniloff.xml
<root>
<body>
<para>
....
</para>
<para>
<a/>
<bookmarkStart id="1"/>
<b/>
....
</para>
<para>
....
</para>
<table>
...
</table>
<c/>
<bookmarkEnd id="1"/>
<d/>
<para>
....
</para>
</body>
</root>
t:\ftemp>type daniloff.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:variable name="bookmarkIDs" select="//bookmarkStart/@id"/>
<xsl:key name="bookmarkStarts" match="bookmarkStart" use="@id"/>
<xsl:key name="bookmarkEnds" match="bookmarkEnd" use="@id"/>
<xsl:template match="node()">
<xsl:choose>
<xsl:when test="some $b in $bookmarkIDs satisfies
( . >> key('bookmarkStarts',$b) and
key('bookmarkEnds',$b) >> . )">
<!--remove the node-->
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
t:\ftemp>xslt2 daniloff.xml daniloff.xsl con
<?xml version="1.0" encoding="UTF-8"?><root>
<body>
<para>
....
</para>
<para>
<a/>
<bookmarkStart id="1"/></para><bookmarkEnd id="1"/>
<d/>
<para>
....
</para>
</body>
</root>
t:\ftemp>
--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--