Re: [xsl] Excluding Matches in Template

Subject: Re: [xsl] Excluding Matches in Template
From: "Karl J. Stubsjoen" <karl@xxxxxxxxxxxxx>
Date: Thu, 26 Jun 2003 08:59:21 -0700
[WENDELL WROTE]

You haven't told us enough to know for sure (you haven't said how the values
of your ID nodes correspond to values in your source document), but my guess
is the easiest thing to do would be wrap the template's contents in an "if"
test, so:


<xsl:template match="z:row">
  <xsl:if test="not(@id = $excludes/ID)">
    Do your thing for rows that pass
  </xsl:if>
</xsl:template>
I'm guessing that your rows have @id attributes on them.


Cheers,
Wendell
Wendell,
This is what I came up with.  It only matches the first node in my exclude
source (see example below).  So how to test for the occurence of @submitid
anywhere within my exclude source.  I've also included sample of the ADO XML
Recordset at bottom.  Thanks!

<xsl:template match="z:row">
 <xsl:variable name="curID"><xsl:value-of
select="@submitid"/></xsl:variable>
 <xsl:if test="not($excludes/ID=$curID)">
    <xsl:call-template name="addval"/>
    </xsl:if>
</xsl:template>

- <EXCLUDE>
  <ID>124266</ID>
  <ID>681002</ID>
  <ID>681144</ID>
  <ID>708136</ID>
  </EXCLUDE>

- <rs:data>
  <z:row submitid="9356" />
  <z:row submitid="67501" />
  <z:row submitid="124266" />
  <z:row submitid="681002" />
  <z:row submitid="681144" />
  <z:row submitid="708136" />
  <z:row submitid="761419" />
  <z:row submitid="852621" />
  <z:row submitid="874541" />
  <z:row submitid="885202" />
  <z:row submitid="890843" />
  <z:row submitid="1005320" />
  <z:row submitid="1017537" />
  <z:row submitid="1062834" />
  <z:row submitid="1122842" />
  <z:row submitid="1123913" />
  <z:row submitid="1123915" />
  </rs:data>

The resulting output is a comma delimited string of the values from z:row
where NOT excluded.  Here is what the above template match returns:

9356,67501,681002,681144,708136,761419,852621,874541,885202,890843,1005320,1
017537,1062834,1122842,1123913,1123915


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread