[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Filtering out nodes between bookmarks

Subject: Re: Filtering out nodes between bookmarks
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 26 Feb 2008 14:03:19 -0500
Re:  Filtering out nodes between bookmarks
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

   <bookmarkStart id="1"/>



  <bookmarkEnd id="1"/>



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:when test="some $b in $bookmarkIDs satisfies
                    ( . >> key('bookmarkStarts',$b) and
                      key('bookmarkEnds',$b) >> . )">
      <!--remove the node-->
        <xsl:copy-of select="@*"/>
        <xsl:apply-templates select="node()"/>

t:\ftemp>xslt2 daniloff.xml daniloff.xsl con
<?xml version="1.0" encoding="UTF-8"?><root>

   <bookmarkStart id="1"/></para><bookmarkEnd id="1"/>



World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.