|
[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
Ed Yau wrote:
Hi
> 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:br/>
<w:t id="b"/>
<w:t id="c"/>
<w:br/>
<w:t id="d"/>
<w:br/>
<w:t id="e"/>
</root>
[30] ~/xslt/tests$ cat intersect.xsl
<xsl:transform
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:w="WordML"
version="1.0">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:variable name="after-1st" select="
/*/w:br[1]/following-sibling::w:t"/>
<xsl:variable name="before-2nd" select="
/*/w:br[2]/preceding-sibling::w:t"/>
<xsl:variable name="intersect" select="
$after-1st[count(.|$before-2nd) = count($before-2nd)]"/>
<xsl:template match="/">
<result>
<xsl:copy-of select="$intersect"/>
</result>
</xsl:template>
</xsl:transform>
[31] ~/xslt/tests$ xalan -XSL intersect.xsl -IN intersect.xml
<result xmlns:w="WordML">
<w:t id="b"/>
<w:t id="c"/>
</result>
[32] ~/xslt/tests$ xsltproc intersect.xsl intersect.xml
<result xmlns:w="WordML">
<w:t id="b"/>
<w:t id="c"/>
</result>
[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"/>
</result>
Regards,
--drkm
___________________________________________________________________________
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
http://fr.answers.yahoo.com
|
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








