Changeset 36880


Ignore:
Timestamp:
2022-11-04T12:10:15+13:00 (18 months ago)
Author:
kjdon
Message:

factored out some code for setting up thisAssocfilepath, as its used in two places. all the places where we want to get something from metadataList, the code was doing (.metadataList)[last()]/metadata - this finds all the descendent metadatalists and chooses the last one. I don't know why this was done. as far as I am aware, we generally want the metadatalist of the current node. the downside of the former strategy is that it is order dependent. for example, when viewing a document, the toplevel metadata list is put after all the subsections, but when document editing, the subsections come after the metadata list. this means that the wrong metadatalist is chosen. I have changed these all back to just using the metadataList of the current node. this assumes that 1. there is only one metadataList, and 2. we are always calling these from hte node where the metadatalist is. there may be cases where we want a child nodes metadatalist - I think this should be handled explicitly, so we always know wheat we are getting, and the tree order doesn't matter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/expand-gsf.xsl

    r36528 r36880  
    140140        did need the character to be entity-mapped -->
    141141    <xsl:template match="gsf:squote"><xslt:text disable-output-escaping="yes">'</xslt:text></xsl:template> 
    142    
     142
     143        <xsl:template name="gsf:assocfilepathVariable">
     144          <xslt:variable name="thisAssocfilepath">                 
     145        <xslt:choose>
     146          <xslt:when test="/page/pageResponse/document">
     147        <xslt:choose>
     148          <xslt:when test="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']">
     149            <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
     150          </xslt:when>
     151          <xslt:otherwise>
     152            <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode[@nodeType='root']/metadataList/metadata[@name='assocfilepath']" />
     153          </xslt:otherwise>
     154        </xslt:choose>
     155          </xslt:when>
     156          <xslt:otherwise>
     157        <xslt:choose>
     158          <xslt:when test="metadataList/metadata[@name='assocfilepath']">
     159            <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='assocfilepath']" />
     160          </xslt:when>
     161          <xslt:otherwise>
     162            <xslt:value-of disable-output-escaping="yes" select="metadataList/metadata[@name='root_assocfilepath']" />
     163          </xslt:otherwise>
     164        </xslt:choose>
     165          </xslt:otherwise>
     166        </xslt:choose>                     
     167      </xslt:variable>
     168         
     169        </xsl:template>
     170       
    143171    <xsl:template match="gsf:image">
    144172        <xslt:variable name="metaName">
     
    150178            </xsl:choose>
    151179        </xslt:variable>
    152         <xslt:variable name="thisAssocfilepath">                   
    153           <xslt:choose>
    154             <xslt:when test="/page/pageResponse/document">
    155               <xslt:choose>
    156             <xslt:when test="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']">
    157               <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
    158             </xslt:when>
    159             <xslt:otherwise>
    160               <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode[@nodeType='root']/metadataList/metadata[@name='assocfilepath']" />
    161             </xslt:otherwise>
    162               </xslt:choose>
    163             </xslt:when>
    164             <xslt:otherwise>
    165               <xslt:choose>
    166             <xslt:when test="(.//metadataList)[last()]/metadata[@name='assocfilepath']">
    167               <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='assocfilepath']" />
    168             </xslt:when>
    169             <xslt:otherwise>
    170               <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
    171             </xslt:otherwise>
    172               </xslt:choose>
    173             </xslt:otherwise>
    174           </xslt:choose>                       
    175         </xslt:variable>
     180                <!-- output the $thisAssocfilepath variable definition-->
     181                <xsl:call-template name="gsf:assocfilepathVariable"/>
    176182          <xslt:if test="./metadataList/metadata[@name = $metaName]">
    177183            <img>
     
    268274            </xsl:when>
    269275            <xsl:when test="@type='source'">
    270               <xslt:variable name="thisAssocfilepath">                 
    271                 <xslt:choose>
    272                   <xslt:when test="/page/pageResponse/document">
    273                 <xslt:choose>
    274                   <xslt:when test="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']">
    275                     <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/metadataList/metadata[@name='assocfilepath']" />
    276                   </xslt:when>
    277                   <xslt:otherwise>
    278                     <xslt:value-of disable-output-escaping="yes" select="/page/pageResponse/document/documentNode[@nodeType='root']/metadataList/metadata[@name='assocfilepath']" />
    279                   </xslt:otherwise>
    280                 </xslt:choose>
    281                   </xslt:when>
    282                   <xslt:otherwise>
    283                 <xslt:value-of disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='root_assocfilepath']" />
    284                   </xslt:otherwise>
    285                 </xslt:choose>                     
    286                 </xslt:variable>
     276                          <xsl:call-template name="gsf:assocfilepathVariable"/>
    287277                <xsl:variable name="image_meta">
    288278                  <xsl:choose>
     
    307297                   disable-output-escaping="yes" select="/page/pageResponse/collection/metadataList/metadata[@name='httpPath']" />/index/assoc/<xslt:value-of
    308298                   disable-output-escaping="yes" select="$thisAssocfilepath" />/<xslt:value-of
    309                    disable-output-escaping="yes" select="(.//metadataList)[last()]/metadata[@name='{$image_meta}']" />
     299                   disable-output-escaping="yes" select="metadataList/metadata[@name='{$image_meta}']" />
    310300                    </xslt:attribute>
    311301                    <xsl:copy-of select="$opt-title"/>
     
    377367                            <xsl:when test="@OIDmetadata">
    378368                                <xsl:variable name="OIDmeta" select="@OIDmetadata"/>
    379                                 <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$OIDmeta}']"/>
     369                                <xslt:value-of select="metadataList/metadata[@name='{$OIDmeta}']"/>
    380370                            </xsl:when>
    381371                            <xsl:otherwise>
     
    617607            <xslt:for-each>
    618608                <xsl:attribute name="select">
    619                   (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/metadata[<xsl:value-of select="$meta_test"/><xsl:if test="@lang">
     609                 <xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>metadataList/metadata[<xsl:value-of select="$meta_test"/><xsl:if test="@lang">
    620610                        <xsl:text> and @lang=</xsl:text>
    621611                        <xsl:value-of select="@lang"/>
     
    648638    <xslt:for-each>
    649639      <xsl:attribute name="select">
    650     (<xsl:if test="@type='collection'">/page/pageResponse/collection/</xsl:if>.//metadataList)[last()]/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>
     640    (<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>
    651641      </xsl:attribute><xsl:choose><xsl:when test='@sort'><xslt:sort/></xsl:when><xsl:when test="gsf:sort"><xslt:sort><xsl:copy-of select="gsf:sort/@*"/></xslt:sort></xsl:when></xsl:choose><xsl:if test='@separator'><xslt:if test='position()>1'><xsl:value-of select='@separator'/></xslt:if></xsl:if>
    652642      <xsl:apply-templates/>
     
    742732            <xsl:for-each select="gsf:metadata">
    743733                <xslt:when>
    744                     <xsl:attribute name="test">(.//metadataList)[last()]/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
     734                    <xsl:attribute name="test">metadataList/metadata[@name='<xsl:call-template name="getMetadataName"/>']</xsl:attribute>
    745735                    <xsl:apply-templates select="."/>
    746736                </xslt:when>
     
    763753            <xsl:choose>
    764754                <xsl:when test="@preprocess">
    765                     <xslt:value-of select="util:{@preprocess}((.//metadataList)[last()]/metadata[@name='{$meta-name}'], /page/@lang )"/>
     755                    <xslt:value-of select="util:{@preprocess}(metadataList/metadata[@name='{$meta-name}'], /page/@lang )"/>
    766756                </xsl:when>
    767757                <xsl:otherwise>
    768                     <xslt:value-of select="(.//metadataList)[last()]/metadata[@name='{$meta-name}']"/>
     758                    <xslt:value-of select="metadataList/metadata[@name='{$meta-name}']"/>
    769759                </xsl:otherwise>
    770760            </xsl:choose>
Note: See TracChangeset for help on using the changeset viewer.