Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

URI x does not identify an external java clas

jehlund
2008-04-29
2012-10-08
  • jehlund
    jehlund
    2008-04-29

    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:

        &lt;java classname=&quot;com.icl.saxon.StyleSheet&quot; classpathref=&quot;project.class.path&quot; fork=&quot;true&quot;&gt;
            &lt;arg line='-t -o &quot;${buildDir}/stage2.fo&quot;'/&gt;
            &lt;arg line=&quot;${saxon.resolver.command.line}&quot;/&gt;
            &lt;arg line='&quot;${buildDir}/stage1.xml&quot;'/&gt;
            &lt;arg line='&quot;${temp.transformation.file}&quot;'/&gt;
            &lt;arg line='&quot;locale=${document.locale}&quot;'/&gt;
            &lt;arg line='&quot;customizationDir=${customization.dir}&quot;'/&gt;
            &lt;arg line='&quot;artworkPrefix=${artworkPrefix}&quot;'/&gt;
            &lt;arg line='&quot;fileProtocolPrefix=${file.protocol.prefix}&quot;'/&gt;
            &lt;arg line='&quot;publishRequiredCleanup=${publish.required.cleanup}&quot;'/&gt;
            &lt;arg line='&quot;disableRelatedLinks=${disableRelatedLinks}&quot;'/&gt;
            &lt;arg line='&quot;pdfFormatter=${pdf.formatter}&quot;'/&gt;
            &lt;sysproperty key=&quot;xml.catalog.files&quot; value=&quot;${xml.catalog.files}&quot;/&gt;
        &lt;/java&gt;
    

    3-The xslt code. Teis java method takes three text arguments. (I've removed company specific names)

        &lt;xsl:value-of select=&quot;myPackage:myMethod(string( @href ), string( @xtrf ), string( ourxmltagindita ))&quot; xmlns:runcmd=&quot;java:myPackage.myClass&quot;/&gt;
    
     
    • Michael Kay
      Michael Kay
      2008-04-29

      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.)

      1. 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"

      2. 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.