Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Passing distinct values as parameters

From: davidcl64@-----.---
To: 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>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent