On 03/11/2013 09:11 AM, Kevin Flynn wrote:
Partially following the advice given below, I am looking into running
the various components of ditac in xproc (calabash) pipelines. When I
run the ditac XSL transformations in calabash I get error messages like
this:

file:/home/kevin/vizdita/ditac-2_4_0/xsl/common/ditacUtil.xsl:917:37:XPST0017:Cannot
find a matching 1-argument function named
{java:com.xmlmind.ditac.xslt.URI}decodeURI(). Note that direct calls to
Java methods are not available under Saxon-HE

I see that saxon HE does indeed not support custom Java functions, and
that the ditac transformations use them. But swapping around the saxon
jar files delivered with ditac and calabash makes no difference:
whatever saxon file is used, ditac works and calabash doesn't. Can you
explain what's going on? Supposing I actually found a solution to this
problem, would I be breaking saxon licensing terms?


We, XMLmind, would never do anything which would infringe Saxon 9 HE licensing terms.

Saxon 9 HE supports custom Java extension functions provided that you declare them the (very) ``hard way''.

See http://www.saxonica.com/feature-matrix.html. Notice that for Saxon HE "Extensibility using reflexion" is not checked, but that "Extensibility using custom classes" is checked.

We have declared our custom Java extension functions as follows (excerpts from ExtensionFunctions.java).

---
/**
 * Registers with Saxon 9.2+ all the extension functions
 * needed to run the XSL stylesheets found in
 * <tt><i>ditac_install_dir</i>/xsl/</tt>.
 * <p>This method must be invoked once per TransformerFactory.
 *
 * @param factory the TransformerFactory pointing to
 * Saxon 9.2+ extension function registry
 * (that is, a <tt>net.sf.saxon.Configuration</tt>).
 * This object must be an instance of
 * <tt>net.sf.saxon.TransformerFactoryImpl</tt>.
 */
public static void registerAll(TransformerFactory factory)
    throws Exception {
    Configuration config = Configuration.newConfiguration();

    config.registerExtensionFunction(new DecodeURIDefinition());
    config.registerExtensionFunction(new UserDirectoryDefinition());
    config.registerExtensionFunction(new UuidUriDefinition());
    config.registerExtensionFunction(new CopyFileDefinition());
    config.registerExtensionFunction(new GetImageWidthDefinition());
    config.registerExtensionFunction(new GetImageHeightDefinition());
    config.registerExtensionFunction(new FormatDateDefinition());

    Method highlightMethod = null;
    try {
        Class<?> xslthlClass =
            Class.forName("net.sf.xslthl.ConnectorSaxonHE");
        highlightMethod = xslthlClass.getMethod("highlight",
                                                XPathContext.class,
                                                String.class,
                                                SequenceIterator.class,
                                                String.class);
    } catch (Exception ignored) {}
    if (highlightMethod != null) {
        config.registerExtensionFunction(
            new HighlightDefinition(highlightMethod));
    }

    ((TransformerFactoryImpl) factory).setConfiguration(config);
}
---

Our custom Java extension functions are also defined in this file:

ditac_install_dir/src/com/xmlmind/ditac/xslt/ExtensionFunctions.java



---
PS: Please note that this level of support is reserved to our customers, so in principle, I'm not supposed to answer to any of your questions. See http://www.xmlmind.com/ditac/support.html#ditac_support_policy


--
XMLmind DITA Converter Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/ditac-support

Reply via email to