Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: Passing distinct values as parameters >Thread Next - Re: Passing distinct values as parameters Re: Passing distinct values as parametersTo: NULL Date: 11/17/2007 11:30:00 AM XSL to parse and display:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:key name="distinct-segcode" match="LOCATION" use="."/>
<xsl:key name="distinct-segcode" match="ROLE" use="."/>
<xsl:template match="/">
<b>Overall</b>
<table border="1">
<tr bgcolor="#00eeff" color="white">
<td><b>Location</b></td>
<td><b>Current</b></td>
<td><b>Pending</b></td>
<td><b>Replacement</b></td>
<td><b>New</b></td>
<td><b>Total</b></td>
</tr>
<!-- this doesn't work - totals end up as 0 -->
<xsl:for-each select="//LOCATION[generate-id()=generate-
id(key('distinct-segcode',.))]">
<xsl:call-template name="writeCount">
<xsl:with-param name="location"><xsl:value-of select="."/
></xsl:with-param>
</xsl:call-template>
</xsl:for-each>
<!-- Calling directly with names works - totals end up as
expected -->
<xsl:call-template name="writeCount">
<xsl:with-param name="location">Florida</xsl:with-param>
</xsl:call-template>
<xsl:call-template name="writeCount">
<xsl:with-param name="location">Washington</xsl:with-
param>
</xsl:call-template>
</table>
</xsl:template>
<xsl:template name="writeCount">
<xsl:param name="location"/>
<xsl:variable name="allReqs"
select="descendant::PERSON[REQ]"/>
<xsl:variable name="allNames"
select="descendant::PERSON[NAME]"/>
<xsl:variable name="allReqsWithNames"
select="$allReqs[count(.|$allNames)=count($allNames)]"/>
<xsl:variable name="allProjected"
select="descendant::PERSON[PROJECTED]" />
<xsl:variable name="locationNodes"
select="descendant::PERSON[LOCATION=$location]"/>
<xsl:variable name="allBackFill"
select="descendant::PERSON[BACKFILL]"/>
<xsl:variable name="allOpenReplacements"
select="$allReqs[count(.|$allBackFill)=count($allBackFill)]"/>
<xsl:variable name="locationBackFill"
select="$locationNodes[count(.|
$allOpenReplacements)=count($allOpenReplacements)]"/>
<xsl:variable name="countLocationNodes"
select="count($locationNodes)"/>
<xsl:variable name="countLocationReqsWithNames"
select="count($locationNodes[count(.|
$allReqsWithNames)=count($allReqsWithNames)])"/>
<xsl:variable name="countLocationReqs"
select="count($locationNodes[count(.|$allReqs)=count($allReqs)])"/>
<xsl:variable name="countLocationProjected"
select="count($locationNodes[count(.|
$allProjected)=count($allProjected)])"/>
<xsl:variable name="countLocationReplacements"
select="count($locationBackFill)"/>
<!--
Intersection Example:
Number of books in the intersection of the two sets
<xsl:value-of
select="count($books_by_rh[count(.|
$books_by_more_than_one_author)=
count($books_by_more_than_one_author)])"/
>
-->
<tr>
<!-- Location -->
<td><xsl:value-of select="$location"/></td>
<!-- Current -->
<td align="right"><xsl:value-of select="$countLocationNodes -
$countLocationReqs"/></td>
<!-- Pending -->
<td align="right"><xsl:value-of
select="$countLocationReqsWithNames"/></td>
<!-- Replacement -->
<td align="right"><xsl:value-of
select="$countLocationReplacements"/></td>
<!-- New -->
<td align="right"><xsl:value-of select="$countLocationReqs -
$countLocationReqsWithNames - $countLocationReplacements"/></td>
<!-- Total -->
<td align="right"><xsl:value-of select="$countLocationNodes"/
></td>
</tr>
</xsl:template>
</xsl:stylesheet>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
