Changeset 34313


Ignore:
Timestamp:
2020-08-06T16:04:04+12:00 (4 years ago)
Author:
ak19
Message:

Correcting XSL to not add classifiers that are empty.

Location:
main/trunk/model-interfaces-dev
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/opotiki/transform/layouts/main.xsl

    r34212 r34313  
    100100<xsl:template name="navBar">
    101101<xsl:choose>
    102 <xsl:when test="page/pageResponse/collection">
    103 <xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier)"/>
     102  <xsl:when test="page/pageResponse/collection">
     103    <!-- Using select statement to count only non-empty elements, is harder than testing
     104     for non-empty elements. Solution of using normalize-space() is from
     105     https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
     106    -->
     107<xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
    104108<xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
    105109
     
    141145
    142146<xsl:template name="Browsing">
    143     <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
     147  <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
     148    <xsl:choose>
     149      <!-- Only display browsing classifiers that have a name.
     150       Those that don't have a name are empty classifiers
     151       denoted by no value/empty value for displayItem name=name elements.
     152       Testing for non empty elements is easy: not() test. -->
     153      <xsl:when test="not(displayItem[@name='name'] ='')">
    144154        <li>
    145155            <xsl:choose>
     
    170180            </a>
    171181        </li>
     182      </xsl:when>
     183    </xsl:choose>
    172184    </xsl:for-each>
    173185</xsl:template>
  • main/trunk/model-interfaces-dev/wmtb/transform/layouts/main.xsl

    r34275 r34313  
    121121<xsl:template name="navBar">
    122122<xsl:choose>
    123 <xsl:when test="page/pageResponse/collection">
    124 <xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier)"/>
    125 <xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
     123  <xsl:when test="page/pageResponse/collection">
     124    <!-- Using select statement to count only non-empty elements, is harder than testing
     125         for non-empty elements. Solution of using normalize-space() is from
     126         https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
     127    -->
     128    <xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
     129    <xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
    126130
    127131<li><a href="{$library_name}">DL Home</a></li>
     
    162166
    163167<xsl:template name="Browsing">
    164     <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
     168  <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
     169    <xsl:choose>
     170      <!-- Only display browsing classifiers that have a name.
     171           Those that don't have a name are empty classifiers
     172           denoted by no value/empty value for displayItem name=name elements.
     173           Testing for non empty elements is easy: not() test. -->
     174      <xsl:when test="not(displayItem[@name='name'] ='')">
    165175        <li>
    166176            <xsl:choose>
     
    191201            </a>
    192202        </li>
     203          </xsl:when>
     204           </xsl:choose>
    193205    </xsl:for-each>
    194206</xsl:template>
Note: See TracChangeset for help on using the changeset viewer.