Use Saxon instead of Xalan
authorMathieu Baudier <mbaudier@argeo.org>
Wed, 24 May 2023 06:54:50 +0000 (08:54 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Wed, 24 May 2023 06:54:50 +0000 (08:54 +0200)
org.argeo.app.servlet.publish/src/org/argeo/app/servlet/publish/DbkServlet.java
org.argeo.app.servlet.publish/src/org/argeo/app/servlet/publish/FopServlet.java

index f2d38e1c0afd00c55726e9bcef5f61de05a98ab6..152df6eb5dca15742aa3fc9cdcf41fe37f083472 100644 (file)
@@ -42,7 +42,6 @@ import javax.xml.transform.stream.StreamSource;
 import org.apache.commons.io.IOUtils;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
-import org.apache.xalan.processor.TransformerFactoryImpl;
 import org.argeo.api.cms.CmsLog;
 import org.argeo.api.cms.ux.CmsTheme;
 import org.argeo.app.docbook.DbkType;
@@ -54,6 +53,8 @@ import org.argeo.jcr.JcrException;
 import org.argeo.jcr.JcrUtils;
 import org.w3c.dom.Document;
 
+import net.sf.saxon.BasicTransformerFactory;
+
 /**
  * A servlet transforming a dbk:* JCR node into HTML, using the DocBook XSL.
  */
@@ -256,9 +257,10 @@ public class DbkServlet extends HttpServlet {
        protected Templates createDocBookTemplates(String xsl) {
                try {
                        if (transformerFactory == null) {
+                               transformerFactory = new BasicTransformerFactory();
                                // We must explicitly use the non-XSLTC transformer, as XSLTC is not working
                                // with DocBook stylesheets
-                               transformerFactory = new TransformerFactoryImpl();
+//                             transformerFactory = new TransformerFactoryImpl();
                        }
                        Source xslSource = new StreamSource(xsl);
                        Templates templates = transformerFactory.newTemplates(xslSource);
index 1ee19f0f58f23688c4b50d1d64dadb5ecf9a1a38..b0c2f636d5f63ae39e86112690b98e8ebe3990bb 100644 (file)
@@ -35,7 +35,6 @@ import org.apache.fop.apps.FOPException;
 import org.apache.fop.apps.Fop;
 import org.apache.fop.apps.FopFactory;
 import org.apache.fop.apps.FopFactoryBuilder;
-import org.apache.xalan.processor.TransformerFactoryImpl;
 import org.apache.xmlgraphics.io.Resource;
 import org.apache.xmlgraphics.io.ResourceResolver;
 import org.argeo.api.acr.Content;
@@ -51,6 +50,8 @@ import org.geotools.data.collection.ListFeatureCollection;
 import org.geotools.data.simple.SimpleFeatureCollection;
 import org.opengis.feature.simple.SimpleFeature;
 
+import net.sf.saxon.BasicTransformerFactory;
+
 /**
  * A servlet transforming an XML view of the data to either FOP or PDF.
  */
@@ -80,7 +81,7 @@ public class FopServlet extends HttpServlet {
                Content content = session.get(path);
 
                // dev only
-               final boolean DEV = false;
+               final boolean DEV = true;
                if (DEV) {
                        try (InputStream in = xslUrl.openStream()) {
                                Source xslSource = new StreamSource(in);
@@ -92,7 +93,7 @@ public class FopServlet extends HttpServlet {
                        }
 
                        Source xmlInput = content.adapt(Source.class);
-                       XmlNormalizer.print(xmlInput,0);
+                       XmlNormalizer.print(xmlInput, 0);
                }
 
                Source xmlInput = content.adapt(Source.class);
@@ -131,6 +132,7 @@ public class FopServlet extends HttpServlet {
                        }
 
                        String p = href.startsWith("/") ? href : path + '/' + href;
+                       p = URLDecoder.decode(p, StandardCharsets.UTF_8);
                        Content subContent = session.get(p);
                        return subContent.adapt(Source.class);
                };
@@ -191,9 +193,7 @@ public class FopServlet extends HttpServlet {
                documentBuilderFactory.setXIncludeAware(true);
                documentBuilderFactory.setNamespaceAware(true);
 
-               // We must explicitly use the non-XSLTC transformer, as XSLTC is not working
-               // with DocBook stylesheets
-               transformerFactory = new TransformerFactoryImpl();
+               transformerFactory = new BasicTransformerFactory();
 //             transformerFactory = TransformerFactory.newDefaultInstance();
                try {
                        String xslStr = LangUtils.get(properties, PROP_ARGEO_FO_XSL);