Changeset 26093


Ignore:
Timestamp:
2012-08-09T13:46:53+12:00 (12 years ago)
Author:
kjdon
Message:

removed old metadata code, and fixed a couple of places where need to call getMetadataName template instead of apply-templates with a mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/config_format.xsl

    r26092 r26093  
    220220      <xsl:variable name="meta_name"><xsl:call-template name="getMetadataName"/></xsl:variable>
    221221      <xsl:variable name="separator"><xsl:choose><xsl:when test="@separator"><xsl:value-of disable-output-escaping='yes' select="@separator"/></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose></xsl:variable>
     222      <xsl:variable name="postest">
     223    <xsl:choose><xsl:when test="@pos = 'first'">position()=1</xsl:when><xsl:when test="@pos = 'last'">position() = last()</xsl:when><xsl:when test="@pos">position() = <xsl:value-of select="@pos"/></xsl:when><xsl:otherwise>true()</xsl:otherwise></xsl:choose>
     224      </xsl:variable>
     225      <xsl:variable name="multiple"><xsl:choose><xsl:when test="@pos">false()</xsl:when><xsl:otherwise>true()</xsl:otherwise></xsl:choose></xsl:variable>
    222226      <xslt:for-each><xsl:attribute name="select">
    223227    <xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>metadataList/metadata[@name='<xsl:value-of select="$meta_name"/>'<xsl:if test="@lang"><xsl:text> and @lang=</xsl:text><xsl:value-of select="@lang"/></xsl:if><xsl:text>]</xsl:text></xsl:attribute>
    224       <xslt:if test="position()>1"><xsl:value-of select="$separator"/></xslt:if>
     228      <xslt:if test="{$postest}">
     229      <xslt:if test="{$multiple} and position()>1"><xsl:value-of select="$separator"/></xslt:if>
    225230      <xsl:choose>
    226231        <xsl:when test="@format">
     
    231236</xsl:otherwise>
    232237      </xsl:choose>
     238    </xslt:if>
    233239    </xslt:for-each>
    234240  </xsl:if>
     
    243249  </xsl:template>
    244250
    245     <xsl:template match="gsf:metadata-last">
    246         <xslt:variable name="langAtt"><xsl:value-of select="@lang"/></xslt:variable>
    247         <xsl:if test="not(@hidden = 'true')">
    248             <xslt:value-of disable-output-escaping="yes">
    249                 <xsl:attribute name="select">
    250                     <xsl:if test="@format">
    251                         <xsl:text>java:org.greenstone.gsdl3.util.XSLTUtil.</xsl:text>
    252                         <xsl:value-of select="@format"/>
    253                         <xsl:text>(</xsl:text>
    254                     </xsl:if>
    255                     <xsl:choose>
    256                         <xsl:when test="@type = 'collection'">
    257                             <xsl:text>/page/pageResponse/collection/metadataList/metadata[@name='</xsl:text>
    258                         </xsl:when>
    259                         <xsl:otherwise>
    260                             <xsl:text>(.//metadataList)[last()]/metadata[@name='</xsl:text>
    261                         </xsl:otherwise>
    262                     </xsl:choose>
    263                     <xsl:apply-templates select="." mode="get-metadata-name"/>
    264                     <xsl:text>'</xsl:text>
    265                     <xsl:if test="@lang">
    266                         <xsl:text> and @lang=$langAtt</xsl:text>
    267                     </xsl:if>
    268                     <xsl:text>]</xsl:text>
    269                     <xsl:if test="@format">
    270                         <xsl:text>, /page/@lang )</xsl:text>
    271                     </xsl:if>
    272                 </xsl:attribute>
    273             </xslt:value-of>
    274         </xsl:if>
    275     </xsl:template>
    276 
    277     <xsl:template match="gsf:metadata" mode="get-metadata-name">
    278         <xsl:if test="@pos">
    279             <xsl:text>pos</xsl:text>
    280             <xsl:value-of select='@pos'/>
    281             <xsl:text>_</xsl:text>
    282         </xsl:if>
    283         <xsl:if test='@select'>
    284             <xsl:value-of select='@select'/>
    285             <xsl:text>_</xsl:text>
    286         </xsl:if>
    287         <xsl:if test="@separator">
    288             <xsl:text>*</xsl:text>
    289             <xsl:value-of select='@separator'/>
    290             <xsl:text>*_</xsl:text>
    291         </xsl:if>
    292         <xsl:value-of select="@name"/>
    293     </xsl:template>
    294 
    295     <xsl:template match="gsf:metadata-old" mode="get-metadata-name">
    296         <xsl:if test="@multiple='true'">
    297             <xsl:text>all_</xsl:text>
    298         </xsl:if>
    299         <xsl:if test='@select'>
    300             <xsl:value-of select='@select'/>
    301             <xsl:text>_</xsl:text>
    302         </xsl:if>
    303         <xsl:if test="@separator">
    304             <xsl:text>*</xsl:text>
    305             <xsl:value-of select='@separator'/>
    306             <xsl:text>*_</xsl:text>
    307         </xsl:if>
    308         <xsl:value-of select="@name"/>
    309     </xsl:template>
    310  
    311     <xsl:template match="gsf:metadata-older">
    312         <xslt:value-of disable-output-escaping="yes">
    313             <xsl:attribute name="select">
    314                 <xsl:text>(.//metadataList)[last()]/metadata[@name="</xsl:text>
    315                 <xsl:choose>
    316                     <xsl:when test="@select='parent'">
    317                         <xsl:text>parent_</xsl:text>
    318                     </xsl:when>
    319                     <xsl:when test="@select='root'">
    320                         <xsl:text>root_</xsl:text>
    321                     </xsl:when>
    322                     <xsl:when test="@select='ancestors'">
    323                         <xsl:text>ancestors'</xsl:text>
    324                         <xsl:value-of select='@separator'/>
    325                         <xsl:text>'_</xsl:text>
    326                     </xsl:when>
    327                     <xsl:when test="@select='siblings'">
    328                         <xsl:text>siblings_'</xsl:text>
    329                         <xsl:value-of select='@separator'/>
    330                         <xsl:text>'_</xsl:text>
    331                     </xsl:when>
    332                 </xsl:choose>
    333                 <xsl:value-of select="@name"/>
    334                 <xsl:text>"]</xsl:text>
    335             </xsl:attribute>
    336         </xslt:value-of>
    337     </xsl:template>
    338  
    339251    <xsl:template match="gsf:text">
    340252        <xslt:call-template name="documentNodeText"/>
     
    345257            <xsl:for-each select="gsf:metadata">
    346258                <xslt:when>
    347                     <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:apply-templates select="." mode="get-metadata-name"/>']</xsl:attribute>
     259                    <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
    348260                    <xsl:apply-templates select="."/>
    349261                </xslt:when>
     
    356268 
    357269    <xsl:template match="gsf:switch">
    358         <xsl:variable name="meta-name"><xsl:apply-templates select="gsf:metadata" mode="get-metadata-name"/></xsl:variable>
     270        <xsl:variable name="meta-name"><xsl:for-each select="gsf:metadata"><xsl:call-template name="getMetadataName"/></xsl:for-each></xsl:variable>
    359271        <xslt:variable name="meta"><xsl:choose><xsl:when test="@preprocess"><xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/></xsl:when><xsl:otherwise><xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/></xsl:otherwise></xsl:choose></xslt:variable>
    360272        <xslt:choose>
Note: See TracChangeset for help on using the changeset viewer.