Subject: Re: Standard XPath expression for the intersection of two node se ts (Was: RE: How can I test if an node included in a nodeset) From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 04 Aug 2000 21:27:41 -0400 |
For those of us who can't wait for the 8th edition,
and who somehow missed the original post, could someone recap what the Kaysian Method is? I'd go look it up in the archives, but they're hosed.
========8<------- Node-set intersection and difference Module 8: XPath and XSLT expressions and advanced techniques Lesson 8-1: Expression Functions
· ( $set1[count(.|$set2)!=count($set2)] | $set2[count(.|$set1)!=count($set1)] )
========8<------- Node-set intersection and difference (cont.) Module 8: XPath and XSLT expressions and advanced techniques Lesson 8-1: Expression Functions
<?xml version="1.0"?><!--diff.xsl--> <!--XSLT 1.0 - http://www.CraneSoftwrights.com/training --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:data="crane" version="1.0">
<data:data> <!--data source for testing purposes--> <item>1</item><item>2</item><item>3</item> <item>4</item><item>5</item><item>6</item> </data:data>
<xsl:template match="/"> <!--root rule--> <xsl:variable name="ns1" select="//item[position()>1]"/> <xsl:variable name="ns2" select="//item[position()<5]"/>
<xsl:for-each select="$ns1[count(.|$ns2)=count($ns2)]"> Intersection: <xsl:value-of select="."/> </xsl:for-each> <xsl:for-each select="( $ns1[count(.|$ns2)!=count($ns2)] | $ns2[count(.|$ns1)!=count($ns1)] )"> Difference: <xsl:value-of select="."/> </xsl:for-each> </xsl:template>
Intersection: 2 Intersection: 3 Intersection: 4 Difference: 1 Difference: 5 Difference: 6 ========8<-------
-- 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 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML services, training, libraries, products. Book: Practical Transformation Using XSLT and XPath ISBN1-894049-05-5 Next public instructor-led training: 2000-09-19/20,2000-10-03, .2000-10-04,2000-10-05,2000-10-19,2000-11-12,2000-12-03/04,2001-01-27
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Standard XPath expression for t, Mike Brown | Thread | MSXML version, Jac Cowan |
RE: Saxon VS XT, Paulo Gaspar | Date | RE: <xsl:stylesheet xmlns..., Paulo Gaspar |
Month |