* Bug #8479 fixed - the latest Saxon version was not supported. 76/12076/2
Clément DAVID [Fri, 19 Jul 2013 13:04:15 +0000 (15:04 +0200)]
Bug: 8479
Change-Id: Idc5d02e8f9feceb8e7798546eddd62b77689a347

scilab/CHANGES_5.5.X
scilab/m4/docbook.m4
scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java

index bd2599d..b1def5b 100644 (file)
@@ -244,6 +244,8 @@ Bug fixes
 
 * Bug #8373 fixed - clear() can now take a matrix of strings argument.
 
+* Bug #8479 fixed - the latest Saxon version was not supported.
+
 * Bug #8511 fixed - sprand used rand and grand functions, and internal state of the random
                     generator was changed.
 
index 0a23f73..d651e0c 100644 (file)
@@ -25,20 +25,28 @@ AC_ARG_WITH(docbook,
                )
 
        for dir in $with_docbook $SCI_SRCDIR_FULL/thirdparty/docbook/ /usr/share/sgml/docbook/stylesheet/xsl/nwalsh /usr/share/docbook2X/xslt/man/ /usr/share/xml/docbook/stylesheet/nwalsh/ /usr/share/xml/docbook/stylesheet/nwalsh/current/ /sw/share/xml/xsl/docbook-xsl /usr/share/xml/docbook/xsl-stylesheets-*/ /usr/share/sgml/docbook/xsl-stylesheets-*/ /usr/share/sgml/docbook/xsl-stylesheets /usr/share/sgml/docbook/xsl-ns-stylesheets-*/; do
-               if test -r "$dir/javahelp/javahelp.xsl" -a "$DOCBOOK_ROOT" = ""; then
+               if test -r "$dir/fo/docbook.xsl" -a "$DOCBOOK_ROOT" = ""; then
                        DOCBOOK_ROOT=$dir
         fi
        done
        if test -z "$DOCBOOK_ROOT"; then
                AC_MSG_ERROR([Could not find the Docbook root directory. If you have installed it on your system and we haven't been able to find it. Please report a bug])
        fi
+       AC_SUBST(DOCBOOK_ROOT)
 
 
        # Saxon XSLT Processor, as the JVM implementation is unable to parse the docbook xsl files
-       AC_JAVA_CHECK_PACKAGE([saxon],[com.icl.saxon.Loader],[Saxon XSLT Processor])
+       # check Saxon-HE 9.5 first then fallback to Saxon-6.5
+       AC_JAVA_CHECK_PACKAGE([saxon9he],[net.sf.saxon.Version],[Saxon XSLT Processor],"yes")
        SAXON=$PACKAGE_JAR_FILE
+       if test -z "$SAXON"; then
+               AC_JAVA_CHECK_PACKAGE([saxon],[net.sf.saxon.Version],[Saxon XSLT Processor],"yes")
+               SAXON=$PACKAGE_JAR_FILE
+       fi
+       if test -z "$SAXON"; then
+               AC_JAVA_CHECK_PACKAGE([saxon],[com.icl.saxon.Loader],[Saxon XSLT Processor])
+               SAXON=$PACKAGE_JAR_FILE
+       fi
        AC_SUBST(SAXON)
 
-AC_SUBST(DOCBOOK_ROOT)
-
 ])
index a9ca6a0..d1f4ac6 100644 (file)
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
@@ -332,7 +333,22 @@ public class BuildDocObject {
 
         final StreamSource xmlSource = new StreamSource(new File(sourceDocProcessed));
 
-        final TransformerFactory tfactory = TransformerFactory.newInstance();
+        /*
+         * We rely on the saxon implementation to compile xsl files (the default JVM implementation failed).
+         *
+         * Supported version :
+         *  * Saxon-HE 9.5 (and may be 8.x too) which handle xinclude, XSLT-2 and has better performances
+         *  * Saxon 6.5 if on the classpath
+         *  * JVM Apache-xerces as a fallback but may probably fail to compile docbook.xsl
+         */
+        TransformerFactory tfactory;
+        try {
+            tfactory = TransformerFactory.newInstance("net.sf.saxon.TransformerFactoryImpl", null);
+        } catch (TransformerFactoryConfigurationError e) {
+            // switch back to the default implementation which may be saxon 6.5 if found on the classpath or the JVM default implementation otherwise
+            tfactory = TransformerFactory.newInstance();
+        }
+
         final Transformer transform = tfactory.newTransformer(new StreamSource(new File(path)));
 
         transform.setParameter("base.dir", this.outputDirectory);