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

Re: Find out the existance of an element between 2 oth

Subject: Re: Find out the existance of an element between 2 others
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Tue, 14 Nov 2006 16:33:32 +0100 (CET)
mulberry nodes between two siblings
Ed Yau wrote:


> What I am trying to express in an Xpath is "Look to see
> where there are any <w:t> elements containing text between
> these 2 <w:br>s".

  What your are looking for is computing the intersection
between two sets.  In XPath 2.0, you have the 'intersect'
operator.  In XSLT 1.0, you can use the following technique,
using the fact that nodes appearing in two sets don't modify
the count of the elements in one set.  Strangely, I didn't
find reference to this in the FAQ, Dave.  Maybe I didn't
look at the right place?

    [29] ~/xslt/tests$ cat intersect.xml
    <root xmlns:w="WordML">
      <w:t id="a"/>
      <w:t id="b"/>
      <w:t id="c"/>
      <w:t id="d"/>
      <w:t id="e"/>

    [30] ~/xslt/tests$ cat intersect.xsl

      <xsl:output omit-xml-declaration="yes" indent="yes"/>

      <xsl:variable name="after-1st"  select="
      <xsl:variable name="before-2nd" select="
      <xsl:variable name="intersect"  select="
          $after-1st[count(.|$before-2nd) = count($before-2nd)]"/>

      <xsl:template match="/">
          <xsl:copy-of select="$intersect"/>


    [31] ~/xslt/tests$ xalan -XSL intersect.xsl -IN intersect.xml
    <result xmlns:w="WordML">
    <w:t id="b"/>
    <w:t id="c"/>

    [32] ~/xslt/tests$ xsltproc intersect.xsl intersect.xml
    <result xmlns:w="WordML">
      <w:t id="b"/>
      <w:t id="c"/>

    [33] ~/xslt/tests$ saxon intersect.xml intersect.xsl
    Warning: at xsl:transform on line 4 of ~/xslt/tests/intersect.xsl:
      Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor
    <result xmlns:w="WordML">
       <w:t id="b"/>
       <w:t id="c"/>




Dicouvrez une nouvelle fagon d'obtenir des riponses ` toutes vos questions ! 
Profitez des connaissances, des opinions et des expiriences des internautes sur Yahoo! Questions/Riponses 

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.