Hello All,

This is the first time I am using XSLT transform to transform an XML file.However, I am using a large XSLT(~2000 lines) written by someone else for the purpose of transformation.When I try to use XslCompiledTransform I get an error:The variable or parameter 'resourcetitle' is either not defined or it is out of scope. I resolved this error using <xsl:variable name=""/> tag.However,I am not sure if this is the right way to resolve the error.

Also,now I am getting another error:The variable or parameter 'dataTableCount' was duplicated within the same scope. Does this mean that there is a problem with the XSLT file? I am not sure how to resolve this error. I am using ASP.NET,C#(VS 2010) environment for the XSLT whereas the person who wrote it is used Perl-CGI script. Can that be a reason why the same XSLT doesn't work in .NET environment? Any suggestions will be grately appreciated.

Recommended Answers

All 4 Replies

The error message is pretty clear. Variables and parameters have a scope in XSLT depending on where they are declared. In general there's "template" scope and "file scope".

A variable only exists and is scoped to he template in which it was declared. So if you have a situation like the following, you're fine. The variables "VarName" are completely different variables because they are declared in separate templates. In the "something" template the variables value is 1, in the "something else" template the variables value is 2. They are basically, completely different varibales that have the same name.

<xsl:template match="something">
	<xsl:variable name="VarName" select="'1'" />
</xsl:template>

<xsl:template match="somethingelse" >
	<xsl:variable name="VarName" select="'2'" />
</xsl:template>

The other scope is across files. Each file that is brought into a xslt using xsl:include has a scope of the file itself. So if you declare 2 variables, that happen to have the same name in 2 separate files, that's ok as well. The scope of each variable is only the FILE which it is declared.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="VarName" select="'1'" />
</xsl:stylesheet>

<!-- Stylesheet B -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:variable name="VarName" select="'2'" />
</xsl:stylesheet>

What you can't do, is declare the same variable TWICE in the same scope. So either of the following situations is wrong. What is the value of "VarName" in each of these transformations? 1 or 2? For that scope, the variable is declared twice.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<!-- Conflict -->
	<xsl:variable name="VarName" select="'1'" />
	<xsl:variable name="VarName" select="'2'" />
</xsl:stylesheet>


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="something" >
		<!-- Conflict -->
		<xsl:variable name="VarName" select="'1'" />
		<xsl:variable name="VarName" select="'2'" />
	</xsl:template>
</xsl:stylesheet>

Here's the catch. If you do the wrong way, and there is a conflict of variables. Some XSLT processors will handle it differently. Some might ignore one of the declarations and execute (it just picks one, but you don't know which). some might be more strict and while it's compiling say, "Sorry you can't declare this twice, so I'm going to fail to run", which is what yours is doing.

Either way, it's really bad coding to do that. Without seeing it and debugging it myself I can't give you the true root cause. But, I'd likely say that this XSLT basically broken, and you're going to have to resolve all those conflicts before it functions.

Thank you very much for the detailed reply. I am attaching the .xsl file along with the points (Error 1- Occurring below the dataset part comment Line 166, Error 2- occurring within the Attribute Coverage display module, below the comment find the subtree to process,Line 1076,I can see that the variable name was used in the same template) where the errors are occurring.Will a Perl CGI script treat this XSLT differently than .NET one? I mean is it possible that it works in that environment but not here?

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:import href="eml-access-2.0.0.xsl"/>
  <xsl:import href="eml-additionalmetadata-2.0.0.xsl"/>
  <xsl:import href="eml-attribute-2.0.0.xsl"/>
  <xsl:import href="eml-attribute-enumeratedDomain-2.0.0.xsl"/>
  <xsl:import href="eml-constraint-2.0.0.xsl"/>
  <xsl:import href="eml-coverage-2.0.0.xsl"/>
  <xsl:import href="eml-dataset-2.0.0.xsl"/>
  <xsl:import href="eml-datatable-2.0.0.xsl"/>
  <xsl:import href="eml-distribution-2.0.0.xsl"/>
  <xsl:import href="eml-entity-2.0.0.xsl"/>
  <xsl:import href="eml-identifier-2.0.0.xsl"/>
  <xsl:import href="eml-literature-2.0.0.xsl"/>
  <xsl:import href="eml-method-2.0.0.xsl"/>
  <xsl:import href="eml-otherentity-2.0.0.xsl"/>
  <xsl:import href="eml-party-2.0.0.xsl"/>
  <xsl:import href="eml-physical-2.0.0.xsl"/>
  <xsl:import href="eml-project-2.0.0.xsl"/>
  <xsl:import href="eml-protocol-2.0.0.xsl"/>
  <xsl:import href="eml-resource-2.0.0.xsl"/>
  <xsl:import href="eml-settings-2.0.0.xsl"/>
  <xsl:import href="eml-software-2.0.0.xsl"/>
  <xsl:import href="eml-spatialraster-2.0.0.xsl"/>
  <xsl:import href="eml-spatialvector-2.0.0.xsl"/>
  <xsl:import href="eml-storedprocedure-2.0.0.xsl"/>
  <xsl:import href="eml-text-2.0.0.xsl"/>
  <xsl:import href="eml-view-2.0.0.xsl"/>
  
  <!-- 
  These import paths will be replaced by config settings
  -->
  <xsl:import href="pageheader.xsl"/>
  <xsl:import href="pagefooter.xsl"/>
  <xsl:import href="page_leftsidebar.xsl"/>
  <xsl:import href="page_rightsidebar.xsl"/>
 
  
 
  <xsl:output method="html" encoding="utf-8"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    indent="yes" />  
  <!-- global variables to store id node set in case to be referenced-->
  <xsl:variable name="ids" select="//*[@id!='']"/>

  <xsl:param name="docid" select=" '' "></xsl:param>
 

  <xsl:template match="/">
    <xsl:param name="docid" select="$docid"></xsl:param>

    
 
    <html>
      <head>
        <link rel="stylesheet" type="text/css"
          href="http://ssd.edu/w3_recommended.css" />
        <link rel="stylesheet" type="text/css"
          href="http://s.edu/css/navigation.css" />
        <link rel="stylesheet" type="text/css"
        href="http://s.edu/css/s.css" />

        <title><xsl:value-of select="$docid"/></title>
      </head>
      <body>
        <!-- begin the header area -->
        <xsl:call-template name="pageheader" />
        <!-- end the header area -->
   
        <!-- begin the left sidebar area -->
        <xsl:call-template name="page_leftsidebar" />
        <!-- end the left sidebar area -->
   
        <!-- begin the content area -->

        <div id="{$mainTableAligmentStyle}">
          <xsl:apply-templates select="*[local-name()='eml']"/>
        </div>
               <div> 
          <xsl:apply-templates select="error"/>
        </div>
        <!-- end the content area -->
   
        <!-- begin the right sidebar area -->
        <xsl:call-template name="page_rightsidebar" />
        <!-- end the right sidebar area -->

        <!-- begin the footer area -->
        <xsl:call-template name="pagefooter" />
        <!-- end the footer area -->
      </body>
    </html>
  </xsl:template>
  
 
  <xsl:template match="error">
    <xsl:value-of select="."/>
  </xsl:template>

   <xsl:template match="*[local-name()='eml']">
     <!-- hang onto first title to pass to child pages -->
     <xsl:param name="resourcetitle">
      <xsl:value-of select="*/title"/> 
     </xsl:param>
     <xsl:param name="packageID">
       <xsl:value-of select="@packageId"/>
     </xsl:param>
   
     <xsl:for-each select="dataset">

       <xsl:call-template name="emldataset">
         <xsl:with-param name="resourcetitle" select="$resourcetitle"></xsl:with-param>
         <xsl:with-param name="packageID" select="$packageID"></xsl:with-param>
       </xsl:call-template>
     </xsl:for-each>
     <xsl:for-each select="citation">
       <xsl:call-template name="emlcitation"/>
     </xsl:for-each>
     <xsl:for-each select="software">
       <xsl:call-template name="emlsoftware"/>
     </xsl:for-each>
     <xsl:for-each select="protocol">
       <xsl:call-template name="emlprotocol"/>
     </xsl:for-each>
     <!-- Additional metadata-->
     <xsl:choose>
       <xsl:when test="$displaymodule='additionalmetadata'">
         <xsl:for-each select="additionalMetadata">
           <xsl:if test="$additionalmetadataindex=position()">
              <div class="{$tabledefaultStyle}">
                 <xsl:call-template name="additionalmetadata"/>
               </div>
            </xsl:if>
         </xsl:for-each>
       </xsl:when>
       <xsl:otherwise>
         <xsl:if test="$displaymodule='dataset'">
           <xsl:if test="$withAdditionalMetadataLink='1'">
             <xsl:for-each select="additionalMetadata">
               <div class="{$tabledefaultStyle}">
                 <xsl:call-template name="additionalmetadataURL">
                    <xsl:with-param name="index" select="position()"/>
                  </xsl:call-template>
               </div>
             </xsl:for-each>
           </xsl:if>
         </xsl:if>
       </xsl:otherwise>
     </xsl:choose>
     <!-- xml format-->
     <xsl:if test="$displaymodule='dataset'">
       <xsl:if test="$withOriginalXMLLink='1'">
         <xsl:call-template name="xml"/>
       </xsl:if>
     </xsl:if>
   </xsl:template>

   <!--********************************************************
                       dataset part
       ********************************************************-->

   <xsl:template name="emldataset">
 <!-- Error 1, variable not defined or out of scope -->
     <xsl:param name="resourcetitle" select="$resourcetitle"/>
     <xsl:param name="entitytype" select="$entitytype"/>
     <xsl:param name="entityindex" select="$entityindex"/> 
     <xsl:param name="packageID"/>  
   
    <xsl:if test="$displaymodule='dataset'">
       <xsl:call-template name="datasetpart">
         <xsl:with-param name="packageID" select="$packageID"></xsl:with-param>
       </xsl:call-template>
    </xsl:if>
     <xsl:if test="$displaymodule='entity'">
       <xsl:call-template name="entitypart"/>
     </xsl:if>
     
     <xsl:if test="$displaymodule='responsibleparties'">
       <xsl:call-template name="responsiblepartiespart">
         <xsl:with-param name="docid" select="$docid"/>
         <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
        <xsl:with-param name="packageID" select="$packageID"/> 
       </xsl:call-template>
     </xsl:if>
     
     <xsl:if test="$displaymodule='coverage' ">
       <xsl:call-template name="coveragepart">
         <xsl:with-param name="docid" select="$docid"/>
         <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
       </xsl:call-template>
     </xsl:if>
   
     <xsl:if test="$displaymodule='coverageall' ">
       <xsl:call-template name="ifcoverage">
         <xsl:with-param name="docid" select="$docid"/>
         <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
         <xsl:with-param name="packageID" select="$packageID"/>
       </xsl:call-template>
     </xsl:if>
    
     <xsl:if test="$displaymodule='methodsall' ">
       <xsl:call-template name="ifmethods">
         <xsl:with-param name="docid" select="$docid"/>
         <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
         <xsl:with-param name="packageID" select="$packageID"/>
       </xsl:call-template>
     </xsl:if>
    <xsl:if test="$displaymodule='attribute'">
       <xsl:call-template name="attributepart"/>
    </xsl:if>
    <xsl:if test="$displaymodule='attributedomain'">
       <xsl:call-template name="datasetattributedomain"/>
    </xsl:if>
    <xsl:if test="$displaymodule='attributecoverage'">
       <xsl:call-template name="datasetattributecoverage">
        <xsl:with-param name="entitytype" select="$entitytype"/>
         <xsl:with-param name="entityindex" select="$entityindex"/>
       </xsl:call-template>
    </xsl:if>
    <xsl:if test="$displaymodule='attributemethod'">
       <xsl:call-template name="datasetattributemethod"/>
    </xsl:if>
    <xsl:if test="$displaymodule='inlinedata'">
       <xsl:call-template name="emlinlinedata"/>
    </xsl:if>
    <xsl:if test="$displaymodule='attributedetail'">
       <xsl:call-template name="entityparam"/>
    </xsl:if>
    <!--   </div> -->
   </xsl:template>

   <!--*************** Data set diaplay *************-->
   <xsl:template name="datasetpart">
       <xsl:param name="packageID"/>  
       <xsl:apply-templates select="." mode="dataset">
        <xsl:with-param name="packageID" select="$packageID"></xsl:with-param> 
       </xsl:apply-templates> 
   </xsl:template>

   <!--************ Entity diplay *****************-->
   <xsl:template name="entitypart">
       <xsl:choose>
         <xsl:when test="references!=''">
            <xsl:variable name="ref_id" select="references"/>
            <xsl:variable name="references" select="$ids[@id=$ref_id]" />
            <xsl:for-each select="$references">
               <xsl:call-template name="entitypartcommon"/>
            </xsl:for-each>
         </xsl:when>
         <xsl:otherwise>
            <xsl:call-template name="entitypartcommon"/>
        </xsl:otherwise>
   </xsl:choose>
    </xsl:template>


    <xsl:template name="entitypartcommon">
 <!--      <tr><th colspan="2">
      Entity Description
      </th></tr> -->
      <xsl:call-template name="identifier">
          <xsl:with-param name="packageID" select="../@packageId"/>
          <xsl:with-param name="system" select="../@system"/>
      </xsl:call-template>
      <tr>
     <td colspan="2">
        <!-- find the subtree to process -->
       <xsl:call-template name="entityparam"/>
     </td>
      </tr>
    </xsl:template>
  
  
  <!--************ Responsible Parties display *****************-->
  <xsl:template name="responsiblepartiespart">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
     <xsl:param name="packageID" select="$packageID"/> 
    <xsl:choose>
      <xsl:when test="references!=''">
        <xsl:variable name="ref_id" select="references"/>
        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
        <xsl:for-each select="$references">
          <xsl:call-template name="responsibleparties">
            <xsl:with-param name="docid" select="$docid"/>
            <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
           
            <xsl:with-param name="packageID" select="$packageID"/> 
          </xsl:call-template>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="responsibleparties">
          <xsl:with-param name="docid" select="$docid"/>
          <xsl:with-param name="resourcetitle" select="$resourcetitle"/>
           <xsl:with-param name="packageID" select="$packageID"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <xsl:template name="responsibleparties">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
    <xsl:param name="packageID" select="$packageID"/> 
    
    
    <xsl:call-template name="datasettitle">
                  <xsl:with-param name="packageID" select="$packageID"/> 
      
    </xsl:call-template>
    <table class="onehundred_percent">            
      <tr><td>
        <xsl:call-template name="datasetmenu">
          <xsl:with-param name="currentmodule">responsibleparties</xsl:with-param>
                     <xsl:with-param name="packageID" select="$packageID"/> 
          
        </xsl:call-template>
      </td></tr>
      <tr><td>
     <!-- 
      
      a 2-column table with the involved parties in boxes across the entire page -->
    <table class="subGroup onehundred_percent">
      <xsl:if test="publisher">
        <th colspan="2">Publishers:</th>
        <xsl:for-each select="publisher">
          <tr>
            <xsl:if test="position() mod 2 = 1">
              <td class="fortyfive_percent">
                <xsl:call-template name="party">
                  <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </td>
              <xsl:for-each select="following-sibling::publisher[position()=1]">
                <td class="fortyfive_percent">
                  <xsl:call-template name="party">
                    <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </td>
              </xsl:for-each>
            </xsl:if>
          </tr>
        </xsl:for-each>
      </xsl:if>
    <xsl:if test="creator">
      <th colspan="2">Owners:</th>
      <xsl:for-each select="creator">
        <tr>
          <xsl:if test="position() mod 2 = 1">
            <td class="fortyfive_percent">
              <xsl:call-template name="party">
                <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
              </xsl:call-template>
            </td>
            <xsl:for-each select="following-sibling::creator[position()=1]">
              <td class="fortyfive_percent">
                <xsl:call-template name="party">
                  <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </td>
            </xsl:for-each>
          </xsl:if>
        </tr>
      </xsl:for-each>
    </xsl:if> 
      
      <!-- add in the contacts using a two column table -->
      <xsl:if test="contact">
        <th colspan="2">Contacts:</th>
        <xsl:for-each select="contact">
          <tr>
            <xsl:if test="position() mod 2 = 1">
              <td class="fortyfive_percent">
                <xsl:call-template name="party">
                  <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </td>
              <xsl:for-each select="following-sibling::contact[position()=1]">
                <td class="fortyfive_percent">
                  <xsl:call-template name="party">
                    <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </td>
              </xsl:for-each>
            </xsl:if>
          </tr>
        </xsl:for-each>
      </xsl:if>
      
      <!-- add in the associatedParty using a two column table -->
      <xsl:if test="associatedParty">
        <th colspan="2">Associated Parties:</th>
        <xsl:for-each select="associatedParty">
          <tr>
            <xsl:if test="position() mod 2 = 1">
              <td class="fortyfive_percent">
                <xsl:call-template name="party">
                  <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </td>
              <xsl:for-each select="following-sibling::associatedParty[position()=1]">
                <td class="fortyfive_percent">
                  <xsl:call-template name="party">
                    <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </td>
              </xsl:for-each>
            </xsl:if>
          </tr>
        </xsl:for-each>
      </xsl:if>
      
      <!-- add in the metadataProviders using a two column table -->
      <xsl:if test="metadataProvider">
        <th colspan="2">Metadata Providers:</th>
        <xsl:for-each select="metadataProvider">
          <tr>
            <xsl:if test="position() mod 2 = 1">
              <td class="fortyfive_percent">
                <xsl:call-template name="party">
                  <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </td>
              <xsl:for-each select="following-sibling::metadataProvider[position()=1]">
                <td class="fortyfive_percent">
                  <xsl:call-template name="party">
                    <xsl:with-param name="partyfirstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="partysecondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </td>
              </xsl:for-each>
            </xsl:if>
          </tr>
        </xsl:for-each>
      </xsl:if>
       </table>
        
      </td></tr>
    </table> <!-- closes the table wrapping the dataset-menu  -->
  </xsl:template>
  
  
  <xsl:template name="coveragepart">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
    <h3>Data Set Coverage</h3>
    <h4><xsl:value-of select="$resourcetitle"/>
       (<a><xsl:attribute name="href">
        <xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>
      </xsl:attribute>return to dataset summary</a>)
    </h4>
    <!-- add in the coverage info -->
    <table class="subGroup onehundred_percent">  
      <tr>
        <!-- add in the geographic coverage info -->
        <td class="fortyfive_percent">
          <xsl:if test="./coverage/geographicCoverage">
            <xsl:for-each select="./coverage/geographicCoverage">
              <xsl:call-template name="geographicCoverage">
                <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
              </xsl:call-template>
            </xsl:for-each>
          </xsl:if>
        </td>
        
       
      </tr>
      <tr>
      <td colspan="2" class="onehundred_percent">
          <xsl:if test="./coverage/taxonomicCoverage">
            <xsl:for-each select="./coverage/taxonomicCoverage">
              <xsl:call-template name="taxonomicCoverage">
                <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
              </xsl:call-template>
            </xsl:for-each>
          </xsl:if>
        </td>
      </tr>
    </table>
    
    
    
    
  </xsl:template>
  
  
  
  
  <xsl:template name="coverageall">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
    <xsl:param name="packageID" select="$packageID"/>
    
    <xsl:call-template name="datasettitle">
      <xsl:with-param name="packageID" select="$packageID"/>
    </xsl:call-template>
    <table>            
      <tr><td>
        <xsl:call-template name="datasetmenu">
          <xsl:with-param name="currentmodule">coverageall</xsl:with-param>
        </xsl:call-template>
      </td></tr>
      <tr><td>
        <!-- 
        <xsl:call-template name="datasetmixed"/> -->
    <h4>
      <xsl:text>Temporal, Geographic and/or Taxonomic information that applies to all data in this dataset: </xsl:text></h4>
    <table class="subGroup onehundred_percent">  
      <tr>
            <!-- add in the resource-level temporal coverage info -->
          <td class="fortyfive_percent">
          <xsl:if test="./coverage/temporalCoverage">
            <!-- print the type of parent element, and title or description -->
          
           <xsl:for-each select="./coverage/temporalCoverage">
          <xsl:call-template name="temporalCoverage">
          <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
          <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
          </xsl:call-template>
            </xsl:for-each>
            <xsl:for-each select="./coverage/geographicCoverage">
              <xsl:call-template name="geographicCoverage">
                <xsl:with-param  name="firstColStyle" select="$firstColStyle"/>
                <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
              </xsl:call-template>
            </xsl:for-each>
            <xsl:for-each select="./coverage/taxonomicCoverage">
              <xsl:call-template name="taxonomicCoverage">
                <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
              </xsl:call-template>
            </xsl:for-each>
            
          </xsl:if> 
          </td>
      </tr>
      </table>
      <!-- 
      next comes the entity level coverages. attribute-level stuff under it's entity name -->
    
  <!--     <table class="subGroup onehundred_percent">
      <tr> -->
        <!--  TO DO: this needs to work for all entity types. choose label based on element name  -->
        <xsl:for-each select="dataTable">
        <xsl:if test="coverage or *//attribute/coverage">
          <h4>
            <xsl:text>Temporal, Geographic and/or Taxonomic information that applies to Data Table: </xsl:text>
          <xsl:value-of select="entityName"/> 
          </h4>
       <!--    <table     class="subGroup onehundred_percent">
            <tr>
                     <th>
         <xsl:text>Applies to Data Table: </xsl:text>
          <xsl:value-of select="entityName"/>
        </th>
            </tr>  -->
                      <xsl:if test="coverage"> <!-- if an entity-level cov tree -->
                        <xsl:for-each select="./coverage/temporalCoverage">
                          <xsl:call-template name="temporalCoverage">
                            <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                            <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                          </xsl:call-template>
                        </xsl:for-each>
                        <xsl:for-each select="./coverage/geographicCoverage">
                          <xsl:call-template name="geographicCoverage">
                            <xsl:with-param  name="firstColStyle" select="$firstColStyle"/>
                            <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                          </xsl:call-template>
                        </xsl:for-each>
                        <xsl:for-each select="./coverage/taxonomicCoverage">
                          <xsl:call-template name="taxonomicCoverage">
                            <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                            <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                          </xsl:call-template>
                        </xsl:for-each>
                      </xsl:if>
            <xsl:if test=".//attribute/coverage"> <!-- an attribute descendant has a cov tree -->
               <xsl:for-each select=".//attribute/coverage">
                 <table  class="subGroup">
                <tr>
                  <th>
                    <!-- create a label for that attribute's coverage info. use the orientation and attr label if it has one -->                 
                <xsl:choose>
                  <xsl:when test="ancestor::dataTable/*//attributeOrientation ='column' ">
                    <xsl:text>Temporal, Geographic and/or Taxonomic information that applies to the data table column: </xsl:text>
                  </xsl:when>
                  <xsl:when test="ancestor::dataTable/*//attributeOrientation ='row' ">
                    <xsl:text>Temporal, Geographic and/or Taxonomic information that applies to the data table row: </xsl:text>
                   </xsl:when>
                </xsl:choose>
                <xsl:choose>
                  <xsl:when test="../attributeLabel">
                    <xsl:value-of select="../attributeLabel"/>
                    <xsl:text> (</xsl:text><xsl:value-of select="../attributeName"/><xsl:text>)</xsl:text>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:value-of select="../attributeName"/>
                  </xsl:otherwise>
                </xsl:choose> <!-- end of cov info label  -->
                  </th>
                </tr>
                   <tr><td>
                <xsl:for-each select="temporalCoverage">            
                  <xsl:call-template name="temporalCoverage">
                    <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </xsl:for-each>
                <xsl:for-each select="geographicCoverage">            
                  <xsl:call-template name="geographicCoverage">
                    <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </xsl:for-each>
                <xsl:for-each select="taxonomicCoverage">            
                  <xsl:call-template name="taxonomicCoverage">
                    <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </xsl:for-each>
                   </td></tr>
                   </table>    <!-- closes the table for the attribute -->
               </xsl:for-each> 
            </xsl:if>
         <!-- </table>  closes the table for the data entity  -->
         </xsl:if>
      </xsl:for-each>
 <!--      </tr>
 </table> -->
    
    
      </td></tr>
    </table> <!-- closes the table wrapping the dataset-menu  -->
    
    
    
    
     </xsl:template>
  
  
  
  
 
  <xsl:template name="ifmethods">
    <xsl:param name="packageID"></xsl:param>
    <xsl:choose>
      <xsl:when test="(//method) or (//methods)">
        <xsl:call-template name="methodsall">
          <xsl:with-param name="docid"/>
          <xsl:with-param name="resourcetitle"/>
          <xsl:with-param name="packageID" select="$packageID"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="nodemissing">
          <xsl:with-param name="resourcetitle"></xsl:with-param>
          <xsl:with-param name="nodemissing_message">No methods information available</xsl:with-param>
          <xsl:with-param name="currentmodule" select="$displaymodule"></xsl:with-param>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
  
  <xsl:template name="ifcoverage">
    <xsl:param name="packageID"></xsl:param>
    <xsl:choose>
      <xsl:when test="(//coverage) or (//coverage)">
        <xsl:call-template name="coverageall">
          <xsl:with-param name="docid"/>
          <xsl:with-param name="resourcetitle"/>
          <xsl:with-param name="packageID" select="$packageID"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="nodemissing">
          <xsl:with-param name="resourcetitle"></xsl:with-param>
          <xsl:with-param name="nodemissing_message">No coverage information available</xsl:with-param>
          <xsl:with-param name="currentmodule" select="$displaymodule"></xsl:with-param>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  
  
  <xsl:template name="nodemissing">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
    <xsl:param name="nodemissing_message"></xsl:param>
    <xsl:param name="currentmodule" select="$currentmodule"/>
    <xsl:call-template name="datasettitle"/>
    <table  class="onehundred_percent">            
      <tr><td>
        <xsl:call-template name="datasetmenu">
          <xsl:with-param name="currentmodule" select="$currentmodule"></xsl:with-param>
        </xsl:call-template>
      </td></tr>
      <tr><td align="center">
        <h4>
        <xsl:value-of select="$nodemissing_message"/>
        </h4>
      </td>
      </tr>
      </table>
  </xsl:template>
  
  
  <xsl:template name="methodsall">
    <xsl:param name="docid" select="$docid"></xsl:param>
    <xsl:param name="resourcetitle" select="$resourcetitle"></xsl:param>
    <xsl:param name="packageID" select="$packageID"/>
    
    <xsl:call-template name="datasettitle">
      <xsl:with-param name="packageID" select="$packageID"></xsl:with-param>
    </xsl:call-template>
    <table  class="onehundred_percent">            
      <tr><td>
        <xsl:call-template name="datasetmenu">
          <xsl:with-param name="currentmodule">methodsall</xsl:with-param>
        </xsl:call-template>
      </td></tr>
      <tr><td>
        
        <h4>
          <xsl:text>These methods, instrumentation and/or protocols apply to all data in this dataset: </xsl:text></h4>
        <table class="subGroup onehundred_percent">  
          <tr>
            <!-- add in the resource-level temporal coverage info -->
            <td class="fortyfive_percent">
              <xsl:if test="./methods">
                <!-- print the type of parent element, and title or description -->
                
                <xsl:for-each select="./methods">
                  <xsl:call-template name="datasetmethod">
                    <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                    <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                  </xsl:call-template>
                </xsl:for-each>
              </xsl:if> 
            </td>
          </tr>
        </table>
        <!-- 
          next comes the entity level coverages. attribute-level stuff under it's entity name -->
        
        <!--     <table class="subGroup onehundred_percent">
          <tr> -->
        <!--  TO DO: this needs to work for all entity types. choose label based on element name  -->
        <xsl:for-each select="dataTable">
          <xsl:if test="(./methods) or (*//attribute/methods) or (./method) or (*//attribute/method) ">
            <h4>
              <xsl:text>These methods, instrumentation and/or protocols apply  to Data Table: </xsl:text>
              <xsl:value-of select="entityName"/> 
            </h4>
            
            <xsl:if test="(./method) or (./methods) "> <!-- first find an entity-level methods tree -->
             <!--  this becomes METHODS in eml 2.1 -->
              <xsl:for-each select="method">
                <xsl:call-template name="datasetmethod">
                  <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                  <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                </xsl:call-template>
              </xsl:for-each>
            </xsl:if>
            <xsl:if test="(*//attribute/methods)  or (*//attribute/method)"> <!-- an attribute descendant has a method tree -->
              <xsl:for-each select="*//attribute/method">
                <table  class="subGroup">
                  <tr>
                    <th>
                      <!-- create a label for that attribute's coverage info. use the orientation and attr label if it has one -->                 
                      <xsl:choose>
                        <xsl:when test="ancestor::dataTable/*//attributeOrientation ='column' ">
                          <xsl:text>These methods, instrumentation and/or protocols apply  to the data table column: </xsl:text>
                        </xsl:when>
                        <xsl:when test="ancestor::dataTable/*//attributeOrientation ='row' ">
                          <xsl:text>These methods, instrumentation and/or protocols apply  to the data table row: </xsl:text>
                        </xsl:when>
                      </xsl:choose>
                      <xsl:choose>
                        <xsl:when test="../attributeLabel">
                          <xsl:value-of select="../attributeLabel"/>
                          <xsl:text> (</xsl:text><xsl:value-of select="../attributeName"/><xsl:text>)</xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                          <xsl:value-of select="../attributeName"/>
                        </xsl:otherwise>
                      </xsl:choose> <!-- end of cov info label  -->
                    </th>
                  </tr>
                  <tr><td>
                    <xsl:for-each select=".">            
                      <xsl:call-template name="datasetmethod">
                        <xsl:with-param name="firstColStyle" select="$firstColStyle"/>
                        <xsl:with-param name="secondColStyle" select="$secondColStyle"/>
                      </xsl:call-template>
                    </xsl:for-each>
                    
                  </td></tr>
                </table>    <!-- closes the table for the attribute -->
              </xsl:for-each> 
            </xsl:if>
            <!-- </table>  closes the table for the data entity  -->
          </xsl:if>
        </xsl:for-each>
        <!--      </tr>
          </table> -->
        
        
      </td></tr>
    </table> <!-- closes the table wrapping the dataset-menu  -->
    
    
    
    
  </xsl:template>
  
  
  
  

   <!--************ Attribute display *****************-->
   <xsl:template name="attributedetailpart">
   </xsl:template>

    <xsl:template name="attributepart">
      <tr><td>
      <h3>Attributes Description</h3>
      </td></tr>
      <tr>
     <td>
        <!-- find the subtree to process -->
      <xsl:if test="$entitytype='dataTable'">
        <xsl:for-each select="dataTable">
            <xsl:if test="position()=$entityindex">
                <xsl:for-each select="attributeList">
                   <xsl:call-template name="attributelist">
                      <xsl:with-param name="docid" select="$docid"/>
                      <xsl:with-param name="entitytype" select="$entitytype"/>
                      <xsl:with-param name="entityindex" select="$entityindex"/>
                   </xsl:call-template>
                </xsl:for-each>
            </xsl:if>
        </xsl:for-each>
      </xsl:if>
    </td>
      </tr>
   </xsl:template>

   <!--************************Attribute Domain display module************************-->
   <xsl:template name="datasetattributedomain">
     <!-- 
       
       these params are used to construct links back , and to provide the attribute name or label as a variable -->
     <xsl:param name="entityindex" select="$entityindex"/>
     <xsl:param name="entitytype" select="$entitytype"/>
     <xsl:param name="attributeindex" select="$attributeindex"/>
     <xsl:variable name="attribute_label">
       <xsl:choose>
         <xsl:when test="*/attributeList/attribute[number($attributeindex)]/attributeLabel ">
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeLabel "/>
           <xsl:text> (</xsl:text><xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/><xsl:text>)</xsl:text>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <!-- 
       begin the display -->
      <tr><td>
        <!--  
          
          Include the label, and a link back to the dataset, or the data table. -->
        <table class="dataset-entity-part">
          <tr>
            <td class="dataset-entity-part-header">
              <h3>Codes and Definitions for: <xsl:value-of select="$attribute_label"/></h3>
            </td>
            <td>
              <div class="dataset-entity-part-backtos">
                <xsl:element name="a">
                  <xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/></xsl:attribute>
                  <xsl:attribute name="class">datasetmenu</xsl:attribute>
                  <xsl:text>Back to Dataset  Summary  and Tabbed View</xsl:text>
                </xsl:element>
              </div>
              <div class="dataset-entity-part-backtos">
                <xsl:element name="a"> 
                  <xsl:attribute name="href">
                    <xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&displaymodule=entity&entitytype=<xsl:value-of select="$entitytype"/>&entityindex=<xsl:value-of select="$entityindex"/>
                  </xsl:attribute>
                  <xsl:attribute name="class">datasetmenu</xsl:attribute>
                  <xsl:text>Back to Data Table Description</xsl:text>
                </xsl:element>
              </div> 
            </td>
          </tr>
        </table>  
        
     <!-- <h3>Attribute Domain</h3> -->
      </td></tr>
      <tr>
     <td>
       <!--
         
         find the subtree to process -->
       <xsl:call-template name="entityparam"/>
    </td>
      </tr>
   </xsl:template>


   <!--************************Attribute Method display module************************-->
   <xsl:template name="datasetattributemethod">
     <!-- 
       
       these params are used to construct links back , and to provide the attribute name or label as a variable -->
     <xsl:param name="entityindex" select="$entityindex"/>
     <xsl:param name="entitytype" select="$entitytype"/>
     <xsl:param name="attributeindex" select="$attributeindex"/>
     <xsl:variable name="attribute_label">
       <xsl:choose>
         <xsl:when test="*/attributeList/attribute[number($attributeindex)]/attributeLabel ">
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeLabel "/>
           <xsl:text> (</xsl:text><xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/><xsl:text>)</xsl:text>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <!-- 
       begin the display -->
     <tr><td>
       <!--  
         
         Include the label, and a link back to the dataset, or the data table. -->
       <table class="dataset-entity-part">
         <tr>
           <td class="dataset-entity-part-header">
             <h3>Method for Attribute: <xsl:value-of select="$attribute_label"/></h3>
           </td>
           <td>
             <div class="dataset-entity-part-backtos">
               <xsl:element name="a">
                 <xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/></xsl:attribute>
                 <xsl:attribute name="class">datasetmenu</xsl:attribute>
                 <xsl:text>Back to Dataset  Summary  and Tabbed View</xsl:text>
               </xsl:element>
             </div>
             <div class="dataset-entity-part-backtos">
               <xsl:element name="a"> 
                 <xsl:attribute name="href">
                   <xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&displaymodule=entity&entitytype=<xsl:value-of select="$entitytype"/>&entityindex=<xsl:value-of select="$entityindex"/>
                 </xsl:attribute>
                 <xsl:attribute name="class">datasetmenu</xsl:attribute>
                 <xsl:text>Back to Data Table Description</xsl:text>
               </xsl:element>
             </div> 
           </td>
         </tr>
       </table>  
     </td>
       </tr>
       <tr>
     <td>
       <!-- 
         
         find the subtree to process -->
       <xsl:call-template name="entityparam"/>
    </td>
      </tr>
   </xsl:template>


   <!--************************Attribute Coverage display module************************-->
   <xsl:template name="datasetattributecoverage">
     <!-- 
       
       these params are used to construct links back , and to provide the attribute name or label as a variable -->
     <xsl:param name="entityindex" select="$entityindex"/>
     <xsl:param name="entitytype" select="$entitytype"/>
     <xsl:param name="attributeindex" select="$attributeindex"/>
     <xsl:variable name="attribute_label">
       <xsl:choose>
         <xsl:when test="*/attributeList/attribute[number($attributeindex)]/attributeLabel ">
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeLabel "/>
           <xsl:text> (</xsl:text><xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/><xsl:text>)</xsl:text>
         </xsl:when>
         <xsl:otherwise>
           <xsl:value-of select="*/attributeList/attribute[number($attributeindex)]/attributeName "/>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:variable>
     <!-- 
       begin the display -->
     <tr><td>
       <!--  
         
         Include the label, and a link back to the dataset, or the data table. -->
       <table class="dataset-entity-part">
         <tr>
           <td class="dataset-entity-part-header">
             <h3>Coverage for Attribute: <xsl:value-of select="$attribute_label"/></h3>
           </td>
           <td>
             <div class="dataset-entity-part-backtos">
               <xsl:element name="a">
                 <xsl:attribute name="href"><xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/></xsl:attribute>
                 <xsl:attribute name="class">datasetmenu</xsl:attribute>
                 <xsl:text>Back to Dataset  Summary  and Tabbed View</xsl:text>
               </xsl:element>
              </div>
             <div class="dataset-entity-part-backtos">
             <xsl:element name="a"> 
             <xsl:attribute name="href">
             <xsl:value-of select="$tripleURI"/><xsl:value-of select="$docid"/>&displaymodule=entity&entitytype=<xsl:value-of select="$entitytype"/>&entityindex=<xsl:value-of select="$entityindex"/>
             </xsl:attribute>
             <xsl:attribute name="class">datasetmenu</xsl:attribute>
             <xsl:text>Back to Data Table Description</xsl:text>
             </xsl:element>
             </div> 
           </td>
         </tr>
       </table>  
      </td></tr>
      <tr>
     <td>
       <!-- 
         
         find the subtree to process -->
       <xsl:call-template name="entityparam"/>
    </td>
      </tr>
   </xsl:template>


   <xsl:template name="entityparam">
     <xsl:choose>
      <xsl:when test="$entitytype=''">
        <xsl:variable name="dataTableCount" select="0"/>
        <xsl:variable name="spatialRasterCount" select="0"/>
        <xsl:variable name="spatialVectorCount" select="0"/>
        <xsl:variable name="storedProcedureCount" select="0"/>
        <xsl:variable name="viewCount" select="0"/>
        <xsl:variable name="otherEntityCount" select="0"/>
        <xsl:for-each select="dataTable|spatialRaster|spatialVector|storedProcedure|view|otherEntity">

        <xsl:if test="'dataTable' = name()">
           <xsl:variable name="currentNode" select="."/>
           <!-- Error 2 -->
           <xsl:variable name="dataTableCount">
            <xsl:for-each select="../dataTable">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
           <xsl:if test="position() = $entityindex">
             <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'dataTable'"/>
                    <xsl:with-param name="entityindex" select="$dataTableCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'dataTable'"/>
                    <xsl:with-param name="entityindex" select="$dataTableCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
                 </xsl:choose>
           </xsl:if>
        </xsl:if>

        <xsl:if test="'spatialRaster' = name()">
          <xsl:variable name="currentNode" select="."/>
           <xsl:variable name="spatialRasterCount">
            <xsl:for-each select="../spatialRaster">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
            <xsl:if test="position() = $entityindex">
           <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'spatialRaster'"/>
                    <xsl:with-param name="entityindex" select="$spatialRasterCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'spatialRaster'"/>
                    <xsl:with-param name="entityindex" select="$spatialRasterCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
                 </xsl:choose>
            </xsl:if>
        </xsl:if>

        <xsl:if test="'spatialVector' = name()">
          <xsl:variable name="currentNode" select="."/>
           <xsl:variable name="spatialVectorCount">
            <xsl:for-each select="../spatialVector">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
           <xsl:if test="position() = $entityindex">
             <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'spatialVector'"/>
                    <xsl:with-param name="entityindex" select="$spatialVectorCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'spatialVector'"/>
                    <xsl:with-param name="entityindex" select="$spatialVectorCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
                 </xsl:choose>
           </xsl:if>
        </xsl:if>

        <xsl:if test="'storedProcedure' = name()">
          <xsl:variable name="currentNode" select="."/>
           <xsl:variable name="storedProcedureCount">
            <xsl:for-each select="../storedProcedure">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
           <xsl:if test="position() = $entityindex">
             <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'storedProcedure'"/>
                    <xsl:with-param name="entityindex" select="$storedProcedureCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'storedProcedure'"/>
                    <xsl:with-param name="entityindex" select="$storedProcedureCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
              </xsl:choose>
           </xsl:if>
        </xsl:if>

        <xsl:if test="'view' = name()">
          <xsl:variable name="currentNode" select="."/>
           <xsl:variable name="viewCount">
            <xsl:for-each select="../view">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
           <xsl:if test="position() = $entityindex">
            <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'view'"/>
                    <xsl:with-param name="entityindex" select="$viewCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'view'"/>
                    <xsl:with-param name="entityindex" select="$viewCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
                 </xsl:choose>
            </xsl:if>
        </xsl:if>

        <xsl:if test="'otherEntityTable' = name()">
          <xsl:variable name="currentNode" select="."/>
           <xsl:variable name="otherEntityCount">
            <xsl:for-each select="../otherEntity">
                  <xsl:if test=". = $currentNode">
                <xsl:value-of select="position()"/>
              </xsl:if>
            </xsl:for-each>
           </xsl:variable>
           <xsl:if test="position() = $entityindex">
            <xsl:choose>
               <xsl:when test="$displaymodule='attributedetail'">
                 <xsl:for-each select="attributeList">
                   <xsl:call-template name="singleattribute">
                    <xsl:with-param name="attributeindex" select="$attributeindex"/>
                    <xsl:with-param name="docid" select="$docid"/>
                    <xsl:with-param name="entitytype" select="'otherEntity'"/>
                    <xsl:with-param name="entityindex" select="$otherEntityCount"/>
                   </xsl:call-template>
                 </xsl:for-each>
               </xsl:when>
               <xsl:otherwise>
                 <xsl:for-each select="../.">
                   <xsl:call-template name="chooseentity">
                    <xsl:with-param name="entitytype" select="'otherEntity'"/>
                    <xsl:with-param name="entityindex" select="$otherEntityCount"/>
                   </xsl:call-template>
                  </xsl:for-each>
                  </xsl:otherwise>
                 </xsl:choose>
             </xsl:if>
          </xsl:if>
        </xsl:for-each>
      </xsl:when>
      <xsl:otherwise>
  <xsl:choose>
     <xsl:when test="$displaymodule='attributedetail'">
      <xsl:for-each select="attributeList">
       <xsl:call-template name="singleattribute">
         <xsl:with-param name="attributeindex" select="$attributeindex"/>
         <xsl:with-param name="docid" select="$docid"/>
         <xsl:with-param name="entitytype" select="$entitytype"/>
         <xsl:with-param name="entityindex" select="$entityindex"/>
       </xsl:call-template>
      </xsl:for-each>
     </xsl:when>
     <xsl:otherwise>
       <xsl:call-template name="chooseentity">
         <xsl:with-param name="entitytype" select="$entitytype"/>
         <xsl:with-param name="entityindex" select="$entityindex"/>
       </xsl:call-template>
     </xsl:otherwise>
    </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>


   <xsl:template name="chooseentity" match='dataset'>
      <xsl:param name="entityindex"/>
      <xsl:param name="entitytype"/>
     <xsl:if test="$entitytype='dataTable'">
        <xsl:for-each select="dataTable">
            <xsl:if test="position()=$entityindex">
                   <xsl:choose>
                     <xsl:when test="references!=''">
                        <xsl:variable name="ref_id" select="references"/>
                        <xsl:variable name="references" select="$ids[@id=$ref_id]" />
                          <xsl:for-each select="$references">
                              <xsl:choose>
                                 <xsl:when test="$displaymodule='entity'">
                                    <xsl:call-template name="dataTable">
                                        <xsl:with-param name="datatablefirstColStyle" select="$firstColStyle"/>
                                        <xsl:with-param name="datatablesubHeaderStyle" select="$subHeaderStyle"/>
                                        <xsl:with-param name="docid" select="$docid"/>
                                        <xsl:with-param name="entitytype" select="$entitytype"/>
                                        <xsl:with-param name="entityindex" select="$entityindex"/>
                                    </xsl:call-template>
                                 </xsl:when>
                                 <xsl:otherwise>
                                    <xsl:call-template name="chooseattributelist"/>
                                 </xsl:otherwise>
                              </xsl:choose>
                          </xsl:for-each>
                     </xsl:when>
                     <xsl:otherwise>
                       <xsl:choose>
                                 <xsl:when test="$displaymodule='entity'">
                                    <xsl:call-template name="dataTable">
                                        <xsl:with-param name="datatablefirstColStyle" select="$firstColStyle"/>
                                        <xsl:with-param name="datatablesubHeaderStyle" select="$subHeaderStyle"/>
                                        <xsl:with-param name="docid" select="$docid"/>
                                        <xsl:with-param name="entitytype" select="$entitytype"/>
                                        <xsl:with-param name="entityindex" select="$entityindex"/>
                                    </xsl:call-template>
                                 </xsl:when>
            

Far too large to review and far too many imports and includes to sift through. Sorry, but for a forum post,I don't have the time to try and debug that. I might have to start charging :) Any one of those files could be part of the problem.

"ill a Perl CGI script treat this XSLT differently than .NET one? I mean is it possible that it works in that environment but not here?"

To answer your question, yes, this could happen. I tried to explain it in the first post. Each XSLT processor has different error handling rules. The Perl one, (whatever processor it is) may be very loose. So if it finds duplicate variables, it just picks one at random and keeps going. .NET more than likely uses MSXML processor, which is obviously tighter when it comes to error handling. So you can take the same code to a different processor and it could behave slightly different.

Thanks,once again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.