Use-when & function-available and Oxygen debugging

1 view
Skip to first unread message

Steven D. Majewski

unread,
Apr 24, 2019, 8:21:15 PM4/24/19
to xtf-user@googlegroups.com List

FYI: I’ve been keeping an old version of Oxygen 10 around to test and debug XTF stylesheets, however even that is awkward at times.  I’ve got a new laptop, and I couldn’t find a version that old on Oxygen’s download site.  I dragged up a copy from my old backups, and found I also had to install and older version of Java to get Oxygen 10 to run.   

I found that by tagging the external function calls with use-when and function-available, I can now run textIndexer stylesheets in current Oxygen 21.  I’ve only done this for the two files that I was required to fix for current testing.  There are quite a number of places to patch. 

I think I tried to do something like this a long while ago. What I didn’t get was that it has to be a compile time conditional using use-when, and not a run time conditional ( if, case ).  

But if anyone has a similar need, this is what I’ve changed in preFilterCommon.xsl (for example)
Not trying to replace the non-available case with anything other than nothing, which is good enough for my testing. 


diff --git a/style/textIndexer/common/preFilterCommon.xsl b/style/textIndexer/common/preFilterCommon.xsl
index 18aa772f..8a88c40f 100644
--- a/style/textIndexer/common/preFilterCommon.xsl
+++ b/style/textIndexer/common/preFilterCommon.xsl
@@ -48,7 +48,7 @@
       <xsl:variable name="docpath" select="saxon:system-id()"/>
       <xsl:variable name="base" select="replace($docpath, '(.*)\.[^\.]+$', '$1')"/>
       <xsl:variable name="dcpath" select="concat($base, '.dc.xml')"/>
-      <xsl:if test="FileUtils:exists($dcpath)">
+      <xsl:if use-when="function-available('FileUtils:exists')" test="FileUtils:exists($dcpath)">
          <xsl:apply-templates select="document($dcpath)" mode="inmeta"/>
          <xsl:if test="not(document($dcpath)//*:identifier)">
             <identifier xtf:meta="true" xtf:tokenize="no">
@@ -253,7 +253,7 @@

       

       <!-- Remove accent marks and other diacritics -->
       <xsl:variable name="no-accents-name">
-         <xsl:value-of select="CharUtils:applyAccentMap('../../../conf/accentFolding/accentMap.txt', $creator)"/>
+         <xsl:value-of use-when="function-available('CharUtils:applyAccentMap')" select="CharUtils:applyAccentMap('../../../conf/accentFolding/accentMap.txt', $creator)"/>
       </xsl:variable>

       

       <!-- Normalize Spaces & Case-->
@@ -461,7 +461,7 @@

       

       <!-- Remove accent marks and other diacritics -->
       <xsl:variable name="no-accents-name">
-         <xsl:value-of select="CharUtils:applyAccentMap('../../../conf/accentFolding/accentMap.txt', $string)"/>
+         <xsl:value-of use-when="function-available('CharUtils:applyAccentMap')" select="CharUtils:applyAccentMap('../../../conf/accentFolding/accentMap.txt', $string)"/>
       </xsl:variable>

Reply all
Reply to author
Forward
0 new messages