This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Intersection Problem


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@codeonline.com
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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]