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

Correcting XSL to not add classifiers that are empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.