Ignore:
Timestamp:
2003-07-02T16:44:49+12:00 (21 years ago)
Author:
kjdon
Message:

radically changed classifiers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/web/interfaces/nzdl/transform/classifier.xsl

    r4711 r4863  
    3434  </xsl:template>
    3535 
    36  
    37   <!-- recursively process all nodes and documents -->
    38  
    3936  <xsl:template match="classifier">
    4037    <xsl:param name="collName"/>
    4138    <xsl:param name="serviceName"/>
    4239    <xsl:variable name="cl_name"><xsl:value-of select="@name"/></xsl:variable>
    43     <xsl:variable name="interleave"><xsl:value-of select="/page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@documentInterleave"/></xsl:variable>
    44     <xsl:variable name="orientation"><xsl:value-of select="/page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@orientation"/></xsl:variable>
    45     <xsl:variable name='mode'><xsl:value-of select='$orientation'/>-<xsl:value-of select='$interleave'/></xsl:variable>
    46     <!-- cant seem to do this any other way, ie mode='{$mode}' doesn't work -->
    4740    <xsl:choose>
    48       <xsl:when test="$mode='horizontal-true'">
    49     <xsl:apply-templates select="." mode='horizontal-true'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
     41      <xsl:when test="/page/pageResponse/service/classifierList/classifier[@name=$cl_name]/@horizontalAtTop">
     42    <xsl:apply-templates select="." mode="horizontal-at-top">
     43      <xsl:with-param name="collName" select="$collName"/>
     44      <xsl:with-param name="serviceName" select="$serviceName"/>
     45    </xsl:apply-templates>
    5046      </xsl:when>
    51       <xsl:when test="$mode='horizontal-false'">
    52     <xsl:apply-templates select="." mode='horizontal-false'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    53       </xsl:when>
    54       <xsl:when test="$mode='vertical-true'">
    55     <xsl:apply-templates select="." mode='vertical-true'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    56       </xsl:when>
    57       <xsl:when test="$mode='vertical-false'">
    58     <xsl:apply-templates select="." mode='vertical-false'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    59       </xsl:when>
     47      <xsl:otherwise>
     48    <xsl:apply-templates select="." mode="default">
     49      <xsl:with-param name="collName" select="$collName"/>
     50      <xsl:with-param name="serviceName" select="$serviceName"/>
     51    </xsl:apply-templates>
     52      </xsl:otherwise>
    6053    </xsl:choose>
    6154  </xsl:template>
    6255 
    63   <!-- vertical and interleave = true: process all document and classifier children together, recursively -->
    64   <xsl:template match="classifier" mode="vertical-true">
     56
     57  <xsl:template match="classifier" mode="horizontal-at-top">
     58    <xsl:param name="collName"/>
     59    <xsl:param name="serviceName"/>
     60    <table width='537'>
     61      <tr valign='top'>
     62    <xsl:for-each select='classifierNode'>
     63      <xsl:apply-templates select='.' mode="horizontal"><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
     64    </xsl:for-each>
     65      </tr>
     66    </table>
     67    <table width='537'>
     68      <tr valign='top'>
     69    <xsl:for-each select='classifierNode'>
     70      <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>
     71    </xsl:for-each>
     72      </tr>
     73    </table>
     74    <xsl:call-template name="greenBar"/>
     75  </xsl:template>
     76
     77  <xsl:template match="classifier" mode="default"> <!-- the default -->
    6578    <xsl:param name="collName"/>
    6679    <xsl:param name="serviceName"/>
     
    7689    <xsl:call-template name="greenBar"/>
    7790  </xsl:template>
     91  <!-- recursively process all nodes and documents -->
    7892 
    79   <!--vertical and interleave = false: process all classifier nodes, recursively, then do the document ones separately -->
    80   <xsl:template match="classifier" mode="vertical-false">
     93  <xsl:template match="documentNode">
    8194    <xsl:param name="collName"/>
    82     <xsl:param name="serviceName"/>
    83     <!-- process the nodes and documents separately-->
    84     <table width='537'>
    85       <xsl:for-each select='classifierNode'>
    86     <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
    87     <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr></xsl:for-each>
    88     </table>
    89     <table width='537'>
    90       <xsl:for-each select='//documentNode'>
    91     <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
    92       </xsl:for-each>
    93     </table>
    94     <xsl:call-template name="greenBar"/>
     95    <td><a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}&amp;dt={@documentType}"><xsl:apply-templates select="." mode="displayNodeIcon"/></a></td><td align='left'><xsl:value-of disable-output-escaping="yes"  select="metadataList/metadata[@name='Title']"/></td>
    9596  </xsl:template>
    96 
    97 
    98   <xsl:template match="classifier" mode="horizontal-true">
    99     <xsl:param name="collName"/>
    100     <xsl:param name="serviceName"/>
    101     <!-- process the nodes and documents together -->
    102    
    103     <table>
    104       <tr valign='top'>
    105     <xsl:for-each select='classifierNode|documentNode'>
    106       <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    107     </xsl:for-each>
    108       </tr>
    109       <tr valign='top'>
    110     <xsl:for-each select='classifierNode|documentNode'>
    111       <td><xsl:text> </xsl:text></td> <!-- the empty cell for the icon -->
    112       <xsl:choose><xsl:when test='name()="classifierNode" and classifierNode|documentNode'>
    113           <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>
    114         </xsl:when>
    115         <xsl:otherwise>
    116           <td><xsl:text> </xsl:text></td>
    117         </xsl:otherwise>
    118       </xsl:choose>
    119     </xsl:for-each>
    120       </tr>
    121     </table>
    122     <xsl:call-template name="greenBar"/>
    123   </xsl:template>
    124 
    125   <xsl:template match="classifier" mode="horizontal-false">
    126     <xsl:param name="collName"/>
    127     <xsl:param name="serviceName"/>
    128     <!-- process the nodes and documents separately-->
    129    
    130     <table width='537'><tr valign='top'>
    131     <xsl:for-each select='classifierNode'>
    132       <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    133     </xsl:for-each></tr>
    134       <tr valign='top'>
    135     <xsl:for-each select='classifierNode'>
    136       <xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></xsl:for-each></tr>
    137     </table>
    138     <table width='537'>
    139       <xsl:for-each select='//documentNode'>
    140     <tr valign='top'><xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
    141       </xsl:for-each>
    142     </table>
    143     <xsl:call-template name="greenBar"/>
    144   </xsl:template>
    145 
    146 <xsl:template match="documentNode">
    147 <xsl:param name="collName">coll-name</xsl:param>
    148 <td><a href="{$library_name}?a=d&amp;c={$collName}&amp;d={@nodeID}"><img src='interfaces/default/images/book.gif' width='18' height='11' border='0'/></a></td><td><xsl:value-of select="metadataList/metadata[@name='Title']"/></td>
    149 </xsl:template>
    15097 
    151   <!-- icon + title -->
     98  <!-- icon + title template-->
    15299  <xsl:template match="classifierNode">
    153100    <xsl:param name="collName"/>
    154101    <xsl:param name="serviceName"/>
    155     <td><a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if><xsl:if test="parent::node()[@orientation='horizontal']">&amp;sib=1</xsl:if></xsl:attribute><img src='interfaces/default/images/bshelf.gif' border='0' width='20' height='16' /></a></td><td align='left'><xsl:value-of select="metadataList/metadata[@name='Title']"/></td>
     102    <td><a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if></xsl:attribute><img src='interfaces/default/images/bshelf.gif' border='0' width='20' height='16' /></a></td><td align='left'><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></td>
    156103  </xsl:template>
    157104 
    158105  <!-- the title is a link: an alternative template -->
    159   <!--
    160   <xsl:template match="classifierNode">
    161     <xsl:param name="collName">coll-name</xsl:param>
    162     <xsl:param name="serviceName">service-name</xsl:param>
    163     <td><a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?a=b&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/><xsl:if test="classifierNode|documentNode">.pr</xsl:if></xsl:attribute><xsl:value-of select="metadataList/metadata[@name='Title']"/></a></td>
     106  <xsl:template match="classifierNode" mode="horizontal">
     107    <xsl:param name="collName"/>
     108    <xsl:param name="serviceName"/>
     109    <xsl:choose>
     110      <xsl:when test="classifierNode|documentNode"><!-- the opened one -->
     111    <td><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></td>
     112      </xsl:when>
     113      <xsl:otherwise>
     114    <td><a><xsl:attribute name='href'><xsl:value-of select='$library_name'/>?a=b&amp;rt=r&amp;s=<xsl:value-of select='$serviceName'/>&amp;c=<xsl:value-of select='$collName'/>&amp;cl=<xsl:value-of select='@nodeID'/></xsl:attribute><xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='Title']"/></a></td>
     115      </xsl:otherwise>
     116    </xsl:choose>
    164117  </xsl:template>
    165   -->
     118 
    166119
    167120<!-- processing for the recursive bit -->
     
    172125    <xsl:param name="collName"/>
    173126    <xsl:param name="serviceName"/>
    174     <td><p/>
    175127    <!-- only do this if there are children -->
    176128    <xsl:if test="classifierNode|documentNode">
    177       <xsl:choose>
    178     <xsl:when test='@orientation="vertical"'>
    179       <table> 
    180         <xsl:for-each select='classifierNode|documentNode'>
    181           <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>
    182           <xsl:if test='name()="classifierNode"'>
    183         <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:apply-templates></tr>
    184           </xsl:if>       
    185         </xsl:for-each>
    186       </table>
    187     </xsl:when>
    188     <xsl:otherwise> <!-- horizontal -->
    189       <table>
    190         <tr valign='top'>
    191           <xsl:for-each select='classifierNode|documentNode'>
    192         <xsl:apply-templates select='.'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    193         <xsl:if test='name()="classifierNode"'>
    194           <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>
    195         </xsl:if>
    196           </xsl:for-each>
    197         </tr>
    198       </table>
    199     </xsl:otherwise>
    200       </xsl:choose>
     129      <td>
     130      <table> 
     131    <xsl:for-each select='classifierNode|documentNode'>
     132      <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>
     133      <xsl:if test='name()="classifierNode"'>
     134        <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:apply-templates></tr>
     135      </xsl:if>       
     136    </xsl:for-each>
     137      </table>
     138      </td>
    201139    </xsl:if>
    202     </td>
    203140  </xsl:template>
    204 
    205   <xsl:template match="classifierNode" mode="process-node-children">
    206     <xsl:param name="collName"/>
    207     <xsl:param name="serviceName"/>
    208     <td><p/>
    209       <xsl:if test='classifierNode'><!-- only do this if there are child nodes - netscape craps out at an empty table like <table  /> -->
    210     <xsl:choose>
    211       <xsl:when test='@orientation="vertical"'>
    212         <table>
    213           <xsl:for-each select='classifierNode'>
    214         <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>
    215         <tr valign='top'><td><xsl:text> </xsl:text></td><xsl:apply-templates select='.' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates></tr>
    216           </xsl:for-each>
    217         </table>
    218       </xsl:when>
    219       <xsl:otherwise>
    220         <table>
    221           <tr valign='top'><xsl:apply-templates select='classifierNode'><xsl:with-param name='collName' select='$collName'/><xsl:with-param name='serviceName' select='$serviceName'/></xsl:apply-templates>
    222         <xsl:apply-templates select='classifierNode' mode='process-node-children'><xsl:with-param name='collName' select='$collName'/></xsl:apply-templates></tr>
    223         </table>
    224       </xsl:otherwise>
    225     </xsl:choose>
    226       </xsl:if>
    227     </td>
    228   </xsl:template>
    229 
     141 
    230142</xsl:stylesheet>
    231143
Note: See TracChangeset for help on using the changeset viewer.