Project

Profile

Help

URI x does not identify an external java clas

Added by Anonymous almost 16 years ago

Legacy ID: #4934626 Legacy Poster: jehlund (jehlund)

There are many hits if you google the phrase "The URI xxx does not identify an external java class". The phrase is an error message from SAXON, and it seem to be many problems that could give the same error message. Here is the solution to my problem. Hope it can help some of you, Regards, Jan-Erik Hagelund Short problem description ------------------------- I'm using the saxon that comes bundeled with IDIOM FO (fo to pdf translater), and have upgraded to SAXON 6.5.5 and JDK 1.6.0_06 smthng. Im using these as part of our DITA XML publishing process. I've extended the DITA XML with our own tags and henche also extended the xslt processing with calls to a java program. The TRAX processor that comes with DITA OPEN Toolkit easily run my java calls in the xsl docs, but SAXON did not. The error message from above seemed impossible to fight down. The solution ------------ BUT in the end we found that (and really, from the ant xml code it is close to obvoious, but often one stares oneself blind ...): SAXON requires its own class path, input into saxon as a parameter named "classpathref". It does NOT read your CLASSPATH evironment variable. Code example ------------ This is two snips from the build.xml read by ant, 1-The classpath contents: <path id="project.class.path"> <pathelement location="/this/is/my/path/to/my/java/classes"/> <pathelement location="${fo.lib.dir}/xep/lib/saxon.jar"/> <pathelement location="${fo.lib.dir}/xml-apis.jar"/> <pathelement location="${fo.lib.dir}/xercesImpl.jar"/> <pathelement location="${fo.lib.dir}/resolver.jar"/> <pathelement location="${fo.lib.dir}/icu4j.jar"/> <pathelement location="${fo.lib.dir}/fo.jar"/> </path> 2-Starting saxon, watch the classpathref variable: <java classname="com.icl.saxon.StyleSheet" classpathref="project.class.path" fork="true"> <arg line='-t -o "${buildDir}/stage2.fo"'/> <arg line="${saxon.resolver.command.line}"/> <arg line='"${buildDir}/stage1.xml"'/> <arg line='"${temp.transformation.file}"'/> <arg line='"locale=${document.locale}"'/> <arg line='"customizationDir=${customization.dir}"'/> <arg line='"artworkPrefix=${artworkPrefix}"'/> <arg line='"fileProtocolPrefix=${file.protocol.prefix}"'/> <arg line='"publishRequiredCleanup=${publish.required.cleanup}"'/> <arg line='"disableRelatedLinks=${disableRelatedLinks}"'/> <arg line='"pdfFormatter=${pdf.formatter}"'/> <sysproperty key="xml.catalog.files" value="${xml.catalog.files}"/> </java> 3-The xslt code. Teis java method takes three text arguments. (I've removed company specific names) <xsl:value-of select="myPackage:myMethod(string( @href ), string( @xtrf ), string( ourxmltagindita ))" xmlns:runcmd="java:myPackage.myClass"/>


Replies (1)

RE: URI x does not identify an external java - Added by Anonymous almost 16 years ago

Legacy ID: #4935084 Legacy Poster: Michael Kay (mhkay)

First, thanks for posting this; it's always useful if you have acquired some experience and solved a problem to make that knowledge available to a wider audience. I've been trying (with limited success) to encourage users to post this kind of material in the Wiki which you can find referenced on every page in the SourceForge project. There are a couple of comments I would make on the content: 1. >SAXON requires its own class path, input into saxon as a parameter named "classpathref". It does NOT read your CLASSPATH evironment variable. Actually, Saxon knows nothing about any parameter named classpathref. This parameter is used by ant: when you run the java task, ant creates a Java VM and initializes its classpath using this variable. Saxon sees the classpath that ant has created for it. (Actually, Saxon doesn't see the classpath at all. It just invokes a class loader provided by the Java VM, and the class loader uses the classpath.) 2. Using the java task (and the Saxon command line interface) is not the best way to run Saxon from within ant. It's much better to use the xslt task. You can request loading of Saxon 6.5.5 by specifying processor="trax", factory name="com.icl.saxon.TransformerFactoryImpl" 3. Even when you are running an XSLT 1.0 stylesheet, I would suggest these days that you use Saxon 9 rather than Saxon 6. But that's your decision.

    (1-1/1)

    Please register to reply