The URI http://expath.org/ns/file does not identify an external Java class

Post here questions and problems related to oXygen frameworks/document types.
stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

The URI http://expath.org/ns/file does not identify an external Java class

Post by stran » Tue Mar 24, 2020 11:07 pm

Hi,

we are using our own version of maketoc and chunktoc (xslt 1). When we execute chunktoc, we have a template that copy a file into another place. Exemple:

Code: Select all

xmlns:file="http://expath.org/ns/file"
    exclude-result-prefixes="file" version="1.0"
    
    
<xsl:template match="imagedata[@fileref='babyyoda.jpg']">
        <xsl:value-of select="file:copy('C:\Users\stran\Documents\testarticle\babyyoda.jpg', 'C:\Users\stran\Documents\testarticle\assoc\babyyoda.jpg')"/>
    </xsl:template>
Chunktoc uses Saxon 6.5.5. But when we try to execute the chuntoc, it displays this message:
The URI http://expath.org/ns/file does not identify an external Java class

Is there a way to copy without having to switch from saxon (we're very dependant on it)?

adrian
Posts: 2659
Joined: Tue May 17, 2005 4:01 pm

Re: The URI http://expath.org/ns/file does not identify an external Java class

Post by adrian » Wed Mar 25, 2020 5:35 pm

Hello,

You seem to be using an EXPath extension module (http://expath.org/ns/file), but AFAIK, there is no such an implementation of EXPath for Saxon 6.5.5. EXPath is available in Saxon 9. The EXPath file module is built into Saxon since 9.5 (available in Saxon-PE and Saxon-EE).

As an alternative you could copy the file by using reflexive extension functions in Java. Like this (using Apache Commons IO):

Code: Select all

  xmlns:file="java:java.io.File"
  xmlns:fileutils="java:org.apache.commons.io.FileUtils"
  exclude-result-prefixes="file fileutils"
  version="1.0">
  
  <xsl:template match="imagedata[@fileref='babyyoda.jpg']">
    <xsl:value-of select="fileutils:copyFile(file:new('C:\Users\stran\Documents\testarticle\babyyoda.jpg'), file:new('C:\Users\stran\Documents\testarticle\assoc\babyyoda.jpg'))"/>
  </xsl:template>
Note that this requires the class org.apache.commons.io.FileUtils from Apache Commons IO, so you also need the commons-io-*.jar in the classpath.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Re: The URI http://expath.org/ns/file does not identify an external Java class

Post by stran » Wed Mar 25, 2020 8:38 pm

It's giving me the message:

There are several Java methods that match equally well

stran
Posts: 12
Joined: Mon Dec 16, 2019 6:51 pm

Re: The URI http://expath.org/ns/file does not identify an external Java class

Post by stran » Wed Mar 25, 2020 10:59 pm

I forgot to add file:new! It works thanks!

Post Reply