Changeset 12029


Ignore:
Timestamp:
2006-07-06T12:51:41+12:00 (18 years ago)
Author:
kjdon
Message:

adedd a new template documentNodeWrapper - this is called for document nodes, which enables the stylesheet to add stuff to nodes in the list without affecting the user defined template. also moved some stuff n classifiertools into a new template to avoid code duplication

Location:
trunk/gsdl3/web/interfaces/default/transform
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/web/interfaces/default/transform/classifiertools.xsl

    r12015 r12029  
    5050    <table width='100%'> 
    5151      <xsl:for-each select='documentNode'>
    52         <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
     52        <tr valign='top'><xsl:call-template name="documentNodeWrapper">
     53        <xsl:with-param name='collName' select='$collName'/>
     54        <xsl:with-param name='serviceName' select='$serviceName'/>
     55          </xsl:call-template></tr>
    5356      </xsl:for-each>
    5457    </table>
     
    6265    <xsl:param name="serviceName"/>
    6366    <table width='100%'>
    64       <xsl:for-each select='classifierNode|documentNode'>
    65     <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
    66     <xsl:if test='name()="classifierNode" and (child::classifierNode or child::documentNode)'>
    67       <!--recurse into the children-->
    68       <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
    69     </xsl:if>
    70       </xsl:for-each>
     67      <xsl:call-template name="processNodeChildren">
     68    <xsl:with-param name='collName' select='$collName'/>
     69    <xsl:with-param name='serviceName' select='$serviceName'/>
     70      </xsl:call-template>
    7171    </table>
    7272    <xsl:call-template name="dividerBar"/>
    7373  </xsl:template>
    74   <!-- recursively process all nodes and documents -->
    7574 
     75  <!-- this is a wrapper node, which the interface can use to add stuff into the query results that isn't part of and doesn't depend on the documentNode template which may come from the collection -->
     76  <xsl:template name="documentNodeWrapper">
     77    <xsl:param name="collName"/>
     78    <xsl:param name="serviceName"/>
     79    <xsl:if test="$berryBaskets = 'true'">
     80      <xsl:call-template name="addBerry">
     81    <xsl:with-param name="collName" select="$collName"/>
     82      </xsl:call-template>
     83    </xsl:if>
     84    <xsl:apply-templates select=".">
     85      <xsl:with-param name="collName" select="$collName"/>
     86      <xsl:with-param name="serviceName" select="$serviceName"/>
     87    </xsl:apply-templates>
     88  </xsl:template>
     89
    7690  <xsl:template match="documentNode">
    7791    <xsl:param name="collName"/>
    7892    <xsl:param name="serviceName"/>
    79     <!--TODO: add berry basket switch -->
    80     <td valign="top"><img class='pick'  id="{$collName}:{@nodeID}" src="interfaces/default/images/berry3.png" alt="in basket" width="15" height="15" border="0"/></td><td><a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}&amp;dt={@docType}&amp;p.a=b&amp;p.s={$serviceName}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a></td><td align='left'><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/></td>
     93    <td><a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}&amp;dt={@docType}&amp;p.a=b&amp;p.s={$serviceName}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a></td><td align='left'><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/></td>
    8194  </xsl:template>
     95 
    8296 
    8397  <!-- icon + title template-->
     
    100114 
    101115
    102 <!-- processing for the recursive bit -->
    103 <!-- if interleave=true, process all child nodes and documents, else just do nodes -->
    104 
    105 
     116  <!-- processing for the recursive bit -->
    106117  <xsl:template match="classifierNode" mode="process-all-children">
    107118    <xsl:param name="collName"/>
    108119    <xsl:param name="serviceName"/>
    109     <!-- only do this if there are children -->
    110     <xsl:if test="classifierNode|documentNode">
    111       <td>
    112       <table> 
    113     <xsl:for-each select='classifierNode|documentNode'>
    114       <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
    115       <xsl:if test='name()="classifierNode" and (child::classifierNode or child::documentNode)'>
    116         <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-all-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
    117       </xsl:if>       
    118     </xsl:for-each>
     120    <td>
     121      <table>
     122    <xsl:call-template name="processNodeChildren">
     123      <xsl:with-param name='collName' select='$collName'/>
     124      <xsl:with-param name='serviceName' select='$serviceName'/>
     125    </xsl:call-template>
    119126      </table>
    120       </td>
    121     </xsl:if>
     127    </td>
    122128  </xsl:template>
    123    
     129 
     130  <xsl:template name="processNodeChildren">
     131    <xsl:param name="collName"/>
     132    <xsl:param name="serviceName"/>
     133    <xsl:for-each select='classifierNode|documentNode'>
     134      <xsl:choose><xsl:when test="name()='documentNode'">
     135      <tr valign='top'>
     136        <xsl:call-template name="documentNodeWrapper">
     137          <xsl:with-param name='collName' select='$collName'/>
     138          <xsl:with-param name='serviceName' select='$serviceName'/>
     139        </xsl:call-template>
     140      </tr>
     141    </xsl:when>
     142    <xsl:otherwise>
     143      <tr valign='top'>
     144        <xsl:apply-templates select='.'>
     145          <xsl:with-param name='collName' select='$collName'/>
     146          <xsl:with-param name='serviceName' select='$serviceName'/>
     147        </xsl:apply-templates>
     148      </tr>
     149      <xsl:if test="child::classifierNode or child::documentNode">
     150        <!--recurse into the children-->
     151        <tr valign='top'><td><xsl:text> </xsl:text></td>
     152          <xsl:apply-templates select='.' mode='process-all-children'>
     153        <xsl:with-param name='collName' select='$collName'/>
     154        <xsl:with-param name='serviceName' select='$serviceName'/>
     155          </xsl:apply-templates>
     156        </tr>
     157      </xsl:if>
     158    </xsl:otherwise>
     159      </xsl:choose>
     160    </xsl:for-each>
     161  </xsl:template>
    124162</xsl:stylesheet>
  • trunk/gsdl3/web/interfaces/default/transform/querytools.xsl

    r12015 r12029  
    100100    <table>
    101101      <xsl:for-each select="documentNodeList/documentNode">
    102     <!--<tr><td><a href="" onClick="addToBasket('{$collName}:{@nodeID}'); return false;">pick</a></td>-->
    103         <!--TODO: add berry basket switch -->
    104     <tr><td valign="top"><img class='pick'  id="{$collName}:{@nodeID}" src="interfaces/default/images/berry3.png" alt="in basket" width="15" height="15" border="0"/></td>
    105 
    106       <xsl:apply-templates select=".">
     102    <tr>
     103      <xsl:call-template name="documentNodeWrapper">
    107104        <xsl:with-param name="collName" select="$collName"/>
    108105        <xsl:with-param name="serviceName" select="/page/pageResponse/service/@name"/>
    109       </xsl:apply-templates>
     106      </xsl:call-template>
    110107    </tr>       
    111108      </xsl:for-each>
    112109    </table>   
    113110  </xsl:template>
     111 
     112  <!-- this is a wrapper node, which the interface can use to add stuff into the query results that isn't part of and doesn't depend on the documentNode template which may come from the collection -->
     113  <xsl:template name="documentNodeWrapper">
     114    <xsl:param name="collName"/>
     115    <xsl:param name="serviceName"/>
     116    <xsl:if test="$berryBaskets = 'true'">
     117      <xsl:call-template name="addBerry">
     118    <xsl:with-param name="collName" select="$collName"/>
     119      </xsl:call-template>
     120    </xsl:if>
     121    <xsl:apply-templates select=".">
     122      <xsl:with-param name="collName" select="$collName"/>
     123      <xsl:with-param name="serviceName" select="$serviceName"/>
     124    </xsl:apply-templates>
     125  </xsl:template>
    114126
    115 
     127 
    116128  <!-- the default doc node template for the query results -->
    117129  <!-- eventually shouldn't need sib arg here -->
Note: See TracChangeset for help on using the changeset viewer.