preFilterCommon fix

39 views
Skip to first unread message

Bridger Dyson-Smith

unread,
May 10, 2013, 1:44:12 PM5/10/13
to XTF Users List
Hi all, 

From looking through the linked XTF instances, I don't think most of you are using Date facets. We've been using them here and have either overlooked or forgotten [1] about a small bug w/regards to that particular facet.

Basically, when we had a date range (e.g., in an EAD, <unitdate>1970-1975</unitdate>), I would see things like the following in <xtf:meta>:
<sort-year xtf:meta="true" xtf:tokenize="no">1970</sort-year>
<facet-date xtf:meta="true" xtf:facet="yes">1970::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">1971::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">1972::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">1973::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">1974::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">1975::01::01</facet-date>
<facet-date xtf:meta="true" xtf:facet="yes">::01::01</facet-date>
The above <xtf:meta> error was, I think, the cause of the attached UI error [2]. Clicking on the "01" link would result in an error page.

I think I've nailed down the problem and pulled together a working fix. In the preFilterCommon's parse:output-range() function, I've modified the first <choose><when> to:

         <xsl:when test="$year2 > $year1 and ($year2 - $year1) &lt; 500">
            <xsl:for-each select="(1 to 500)">
               <xsl:if test="$year1 + position() - 1 &lt;= $year2">
                  <xsl:value-of select="concat($year1 + position() - 1, ' ')"/>
               </xsl:if>
            </xsl:for-each>
         </xsl:when>

I haven't found a spot where the change causes problems, but I wanted to ask here if there seemed to be any glaring problems with the above. I made one other minor tweak to the stylesheet, applying a normalize-space() function on the <sort-year> result. 

If there's interest, I'm happy to share a diff or the stylesheet. 
Thanks for your time.
Cheers,
Bridger
--
Digital Initiatives
University of Tennessee Libraries

[1] Maybe BOTH!! :)
[2] date-indexing-correction.png
date-indexing-correction.png

Tracy Seneca

unread,
Oct 22, 2013, 12:40:46 PM10/22/13
to xtf-...@googlegroups.com

Thank you for this; very helpful!

- Tracy Seneca
University of Illinois at Chicago
Reply all
Reply to author
Forward
0 new messages