Saxon extension JAR error in the DITA-OT 4.1.2

34 views
Skip to first unread message

Toshihiko Makita

unread,
Dec 21, 2023, 4:15:37 AM12/21/23
to DITA-OT Users
Hi All,
I'm developing Saxon extension library described in DITA-OT page.
Here is my plugin.xml.
<plugin id="com.acme.annotated.xml">
  <feature extension="dita.conductor.target.relative" value="integrator.xml" type="file"/>
  <feature extension="dita.conductor.lib.import" file="lib/uri-util-0.1.jar"/>
  <transtype name="acme.annotated.xml" desc="XML">
    <param name="output.file" desc="Output annotated XML file name" type="file"/>
    ...
  </transtype>
</plugin>


Here is uri-util-0.1.jar structure.
uri-util-0.1.jar
|   .classpath
|   .project
|
+---com
|   \---antennahouse
|       \---xslt
|           \---extension
|                   Main.class
|                   UriUtil.class
|                   UriUtilFunctionDefinition$1.class
|                   UriUtilFunctionDefinition.class
|
+---META-INF
|   |   MANIFEST.MF
|   |
|   \---services
|           net.sf.saxon.lib.ExtensionFunctionDefinition
|
\---src
        module-info.java

The content of net.sf.saxon.lib.ExtensionFunctionDefinition.

com.antennahouse.xslt.extension.UriUtilFunctionDefinition

When I run dita command, I got the following error.

PS D:\DITA-OT\dita-ot-4.1.2> bin/dita --install -v
Searching for integrator.xml ...

integrate:
Error: net.sf.saxon.lib.ExtensionFunctionDefinition: Provider com.antennahouse.xslt.extension.UriUtilFunctionDefinition not found

To make it sure, I wrote following code in UriUtilFunctionDefinition.java.

package com.antennahouse.xslt.extension;


import net.sf.saxon.expr.XPathContext;

import net.sf.saxon.lib.ExtensionFunctionCall;

import net.sf.saxon.lib.ExtensionFunctionDefinition;

import net.sf.saxon.om.Sequence;

import net.sf.saxon.om.StructuredQName;

import net.sf.saxon.trans.XPathException;

import net.sf.saxon.value.SequenceType;

import net.sf.saxon.value.StringValue;


public class UriUtilFunctionDefinition extends ExtensionFunctionDefinition{

@Override

public SequenceType[] getArgumentTypes() {

return new SequenceType[] { SequenceType.SINGLE_STRING, SequenceType.SINGLE_STRING};

}

@Override

public StructuredQName getFunctionQName() {

return new StructuredQName("", "java:com.antennahouse.xslt.extension.UriUtil", "getRelativePath");

}


@Override

public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {

return SequenceType.SINGLE_STRING;

}

@Override

public ExtensionFunctionCall makeCallExpression() {

return new ExtensionFunctionCall() {

@Override

public Sequence call(XPathContext context, Sequence[] arguments) throws XPathException {

try {

String dest = ((StringValue) arguments[0]).getStringValue();

String base = ((StringValue) arguments[1]).getStringValue();

String result = UriUtil.getRelativePath(dest, base);


return StringValue.makeStringValue(result);


} catch (Exception ex) {

throw new XPathException(ex);

}

}

};

}

}


If someone has solution, please advise.

Toshihiko Makita
Antenna House, Ina Branch.


Radu Coravu

unread,
Dec 21, 2023, 4:49:45 AM12/21/23
to Toshihiko Makita, DITA-OT Users
Hi Toshihiko,

This discussions list is kind of deprecated and no followed by many, maybe in the future you can start a discussion here:
The error seems to indicate the "services/net.sf.saxon.lib.ExtensionFunctionDefinition" file from your JAR library is properly read. But that the value "com.antennahouse.xslt.extension.UriUtilFunctionDefinition" would not seem to indicate to a class found in the classpath.
I do not see anything wrong in your JAR's folder structure. Out of curiosity if you copy the "uri-util-0.1.jar" to the "DITA-OT/lib" folder and then run the integrator does it work?

Regards,
Radu

--
You received this message because you are subscribed to the Google Groups "DITA-OT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dita-ot-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/dita-ot-users/32ce94a3-ab8b-4bba-8c6e-64bc5236e8f6n%40googlegroups.com.

Toshihiko Makita

unread,
Dec 21, 2023, 5:34:51 AM12/21/23
to DITA-OT Users
Hi Radu,
Thank you for your quick reply!!
> if you copy the "uri-util-0.1.jar" to the "DITA-OT/lib" folder and then run the integrator does it work?
The dita command result:

PS D:\DITA-OT\dita-ot-4.1.2> bin/dita --install -v
Searching for integrator.xml ...

integrate:

configuration-jar:
      [jar] Building jar: D:\DITA-OT\dita-ot-4.1.2\lib\dost-configuration.jar


Also, "EVERYTHING" in Saxon extension function worked as expected. Very appreciated!

Regards,
Toshihiko Makita
2023年12月21日木曜日 18:49:45 UTC+9 raduc...@gmail.com:

Radu Coravu

unread,
Dec 21, 2023, 5:50:13 AM12/21/23
to Toshihiko Makita, DITA-OT Users
Hi Toshihiko,
I think it's a chicken and egg problem of sorts. In order for the "dita" command to have your JAR library in the classpath, it would need to  be referenced in the "DITA-OT/config/env.sh" file but in order to be referenced there the "dita --install" needs to run successfully but it cannot run successfully because the JAR library is not in the path. Looks like a DITA OT integration bug in a way. I'm curious if you have the stack trace for the original error to see why the "dita --install" was attempting to load content from your JAR although it was not in the classpath.
Regards,
Radu



Toshihiko Makita

unread,
Dec 22, 2023, 6:59:42 AM12/22/23
to DITA-OT Users
Hi Radu,
I missed your reply.
> I think it's a chicken and egg problem of sorts.
I do agree! Unfortunately, I don't have the stack trace of the dita command. All of the exceptions seem to be caught.
Should I post a bug report to the DITA-OT GitHub issue tracker?

Regards,
Toshihiko Makita


2023年12月21日木曜日 19:50:13 UTC+9 raduc...@gmail.com:

Radu Coravu

unread,
Dec 22, 2023, 7:24:37 AM12/22/23
to Toshihiko Makita, DITA-OT Users
Hi Toshihiko,
It you manage to put together a small sample plugin which can be used to reproduce the problem I think indeed opening a DITA OT issue would be appropriate.
Regards,
Radu

Reply all
Reply to author
Forward
0 new messages