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

Re: Break Point in XML document: XPATH??

Subject: Re: Break Point in XML document: XPATH??
From: Niko Matsakis <niko@xxxxxxxxxxxxx>
Date: Mon, 06 Jan 2003 14:43:33 -0500
xpath xsl break
well, one way that is super slow is:

<xsl:copy-of select="following-sibling::elem2[not (contains (preceding-sibling::elem-2, "break"))]"/>
<!-- select all elem2 nodes that are have no preceding sibling that has the word break in it -->


a faster way might be:

<!-- create a variable with the index of the word break -->
<xsl:variable name="break-pos">
 <xsl:for-each select="following-sibling::elem2[contains (., "break")]">
    <xsl:value-of select="position()"/>
 </xsl:for-each>
</xsl:variable>

<!-- copy all elem2's that occur before that index -->
<xsl:copy-of select="following-sibling::elem2[position() < number($break-pos)"/>


this assumes that only one elem2 contains the word 'break'.


Niko Matsakis DataPower technology


Chandra - wrote:


Hi all,
I had earlier emailed regarding a break point in the an xml document. I need to transform the following document into another Xml document such that any tag below "break" should not be displayed.
The XSLT transformation is such that I am having to do this from the
<xsl:template match= "elem1"> block. So my context or current node is <elem1>. How do I do it from here. I am having difficulty in writing the proper XPath exressions for this. Any help is greatly appreciated.
Thanks
Chandra


<root>
    <elem1>
        data1
    </elem1>


<elem2> <selem2> data2 </selem2> </elem2>

<!---Below this all should be removed except for root tag-->
    <elem2>
      <selem2>
         <ssubelem2>
           <sssubelem2 attr="break">break
           </sssubelem2>
         </ssubelem2>
      </selem2>
    </elem2>


<elem2> <selem2> data2 </selem2> </elem2>

    <elem2>
          <selem2>
             data2
          </selem2>
    </elem2>


</root>



_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list





XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.