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

RE: Intersection Problem

Subject: RE: Intersection Problem
From: "Jarno Elovirta" <jarno@xxxxxxxxxxxxxx>
Date: Wed, 26 Jul 2000 08:27:50 +0300
xslt intersection
Hi

> I want to be able to get the result tag in document 1 for those statResult
> which contain the same drilldownTypes (number and content) as in
> document 2.

The style sheet below gives you the results you wanted, but I'm not dead
sure I solved the problem you had... I think I did... but anyhow, the style
sheet is a stupid hack with the 1/0 thingamajig and probably not that
efficient, but maybe it'll give you some ideas on how you might do it
better. The stat1.xml is your document 1 wrapped in statResults element to
make it XML and stat2.xml is your document 2.

[c:\temp]type stat.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml"
            indent="yes"/>

<xsl:variable name="refDrillTypes"
select="document('stat2.xml')/drilldowns/drilldown" />

<xsl:template match="statResults">
  <results>
    <xsl:apply-templates select="statResult" />
  </results>
</xsl:template>

<xsl:template match="statResult">
  <xsl:variable name="isMatch">
    <xsl:for-each select="drilldowns/drilldown/drilldownType">
      <xsl:choose>
        <xsl:when test="$refDrillTypes/drilldownType[text() =
current()/text()]">
          <xsl:text>1</xsl:text>
        </xsl:when>
        <xsl:otherwise>
          <xsl:text>0</xsl:text>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:for-each>
  </xsl:variable>
  <xsl:if test="not(contains($isMatch, '0')) and count($refDrillTypes) =
string-length($isMatch)">
    <xsl:copy-of select="result" />
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

[c:\temp]saxon stat1.xml stat.xsl
<?xml version="1.0" encoding="utf-8"?>
<results>
   <result>-8225.23157709444</result>
   <result>-4657.82</result>
</results>

VNV Nation: "Darkangel" this time :)

--
Jarno Elovirta     jarno.elovirta@xxxxxxxxxxxxxx
CODEONLINE Ltd.    http://www.codeonline.com
P.O. Box 538 (Ukonvaaja 2 A), FIN-02130 Espoo, Finland
Mobile: +358 40 772 6785 Fax: +358 9 4393 0410

"Hoc non credo; toga mea surrepta est iterum!"


 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.