Command line problem

64 views
Skip to first unread message

Byomokesh

unread,
Dec 18, 2009, 8:47:13 AM12/18/09
to EXPath
Hi,

I have downloaded EXPath ZIP Facitlity. But I could not identify how I
will run that. I have extracted expath-zip-saxon and create xsl file
(which is given by Floerent Georges). When I run this xsl files it
will showing error. I think my command line is wrong. Please anyone
advice what I will do.

My Run Command

D:\saxonhe9-2-0-3j>java -jar saxon9he.jar
d:\saxonhe9-2-0-3j\expath-zip\saxon\expath-zip-saxon.jar
d:/zipxsl/test/zip-list.xsl


Error Showing…

Error at xsl:sequence on line 11 column 51 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 19 on line 11 in {java:entries
($href)}:
Cannot find a matching 1-argument function named
{java:org.expath.saxon.Zip}
entries()
Error at xsl:sequence on line 17 column 60 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 28 on line 17 in {java:xml-entry
($href, $
path)}:
Cannot find a matching 2-argument function named
{java:org.expath.saxon.Zip}
xml-entry()
Error at xsl:sequence on line 23 column 61 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 29 on line 23 in {java:html-entry
($href,
$path)}:
Cannot find a matching 2-argument function named
{java:org.expath.saxon.Zip}
html-entry()
Error at xsl:sequence on line 29 column 61 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 29 on line 29 in {java:text-entry
($href,
$path)}:
Cannot find a matching 2-argument function named
{java:org.expath.saxon.Zip}
text-entry()
Error at xsl:sequence on line 35 column 63 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 31 on line 35 in {java:binary-
entry($href
, $path...}:
Cannot find a matching 2-argument function named
{java:org.expath.saxon.Zip}
binary-entry()
Error at xsl:sequence on line 40 column 51 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 19 on line 40 in {java:zip-file
($zip)}:
Cannot find a matching 1-argument function named
{java:org.expath.saxon.Zip}
zip-file()
Error at xsl:sequence on line 46 column 66 of expath-zip-saxon.xsl:
XPST0017: XPath syntax error at char 34 on line 46 in {...:update-
entries($zip
, $outp...}:
Cannot find a matching 2-argument function named
{java:org.expath.saxon.Zip}
update-entries()
Failed to compile stylesheet. 7 errors detected.
---------------------

I want to create epub file from directly from the style sheet.


Thanks
Byomokesh

Florent Georges

unread,
Dec 18, 2009, 9:09:18 AM12/18/09
to exp...@googlegroups.com
2009/12/18 Byomokesh wrote:

> D:\saxonhe9-2-0-3j>java -jar saxon9he.jar
> d:\saxonhe9-2-0-3j\expath-zip\saxon\expath-zip-saxon.jar
> d:/zipxsl/test/zip-list.xsl

The JAR file must be in the Java classpath, by using the -cp option
of Java. Furthermore, when using the -jar option, the -cp is ignored.
When not using -jar you must explicitly set the main class too (here
net.sf.saxon.Transform).

And finally, you must provide Saxon with the option -xsl: to
identify the stylesheet, and either an input document (-s:) or a named
template (-it:). So given your stylesheet main entry point is a
template named "main", the correct command should be (replace the
"..." with the right paths for you):

java -cp ".../saxon9he.jar;.../expath-zip-saxon.jar" \
net.sf.saxon.Transform \
-xsl:d:/zipxsl/test/zip-list.xsl \
-it:main

Beware this long line has been cut on several lines using "\" at the
end of each line. I am not sure this is possible to use that under
Windows, so maybe it is easier to copy all that on one single line
(without the "\"s) in order to test it...

If this still does not work, please give the exact command line you
used, as well as the stylesheet d:/zipxsl/test/zip-list.xsl.

Thanks for your report!

Regards,

--
Florent Georges
http://www.fgeorges.org/

Michael Kay

unread,
Dec 18, 2009, 9:24:47 AM12/18/09
to exp...@googlegroups.com

Saxon-HE will not run extension functions dynamically loaded from the
classpath - it will only run the new kind of "integrated extension
functions", and these have to be explicitly registered with the Saxon
configuration.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay

> -----Original Message-----
> From: exp...@googlegroups.com
> [mailto:exp...@googlegroups.com] On Behalf Of Byomokesh
> Sent: 18 December 2009 13:47
> To: EXPath
> Subject: [expath] Command line problem
>
> Hi,
>
> I have downloaded EXPath ZIP Facitlity. But I could not
> identify how I will run that. I have extracted
> expath-zip-saxon and create xsl file (which is given by
> Floerent Georges). When I run this xsl files it will showing
> error. I think my command line is wrong. Please anyone advice
> what I will do.
>
> My Run Command
>
> D:\saxonhe9-2-0-3j>java -jar saxon9he.jar
> d:\saxonhe9-2-0-3j\expath-zip\saxon\expath-zip-saxon.jar
> d:/zipxsl/test/zip-list.xsl
>
>

> Error Showing.

> --
>
> You received this message because you are subscribed to the
> Google Groups "EXPath" group.
> To post to this group, send email to exp...@googlegroups.com.
> To unsubscribe from this group, send email to
> expath+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/expath?hl=en.
>
>

Florent Georges

unread,
Dec 18, 2009, 10:23:29 AM12/18/09
to exp...@googlegroups.com
2009/12/18 Michael Kay wrote:

Hi,

> Saxon-HE will not run extension functions dynamically loaded
> from the classpath - it will only run the new kind of
> "integrated extension functions", and these have to be
> explicitly registered with the Saxon configuration.

Right, thanks for pointing that out. I tend to forget about
that point as the EXPath Packaging System takes care of it:

> # the Saxon version
> saxon -?
Saxon-HE 9.2.0.3J from Saxonica
...

> # the packages installed in the repository
> xrepo list
expath-http-client-0.1
functx-1.0
fxsl-1.0

> # the transform fails because the ZIP pkg is not installed
> saxon -xsl:zip-list.xsl -it:main
Error at xsl:import on line 6 column 58 of zip-list.xsl:
XTSE0165: java.io.FileNotFoundException:
http://www.expath.org/mod/zip.xsl
Failed to compile stylesheet. 1 error detected.

> # install the ZIP pkg directly from cxan.org
> xrepo install http://www.cxan.org/tmp/expath-zip-0.1.xar
Install module EXPath ZIP Facility? [true]:
Install it to dir [expath-zip-0.1]:

> # we can see the package is now installed
> xrepo list
expath-http-client-0.1
expath-zip-0.1
functx-1.0
fxsl-1.0

> # and now the transform succeeds
> saxon -xsl:zip-list.xsl -it:main
<?xml version="1.0" encoding="UTF-8"?>
<zip:file xmlns:zip="http://www.expath.org/mod/zip" href="images.zip">
<zip:file name="web1.jpg" size="35038" time="2009-05-08T17:42:24"/>
<zip:file name="web3.jpg" size="31214" time="2009-05-08T17:42:22"/>
<zip:file name="web2.jpg" size="34960" time="2009-05-08T17:42:24"/>
</zip:file>

Byomokesh, so you either have to: use Saxon 9.1, or use EXPath
Packaging System. You should find enough information on its
homepage <http://www.expath.org/modules/pkg/>, do not hesitate to
ask here if something is missing.

I am afraid though that there is no script for Windows to
launch Saxon from the command line and automatically configure
the repository (but that works on Cygwin). It should be possible
from a batch file, but I do not know that language. I would be
glad to help someone willing to write such a script!

Byomokesh Sahoo

unread,
Dec 21, 2009, 4:31:33 AM12/21/09
to exp...@googlegroups.com
Hi,

Thanks for reply.

I required only to create XSLT file for epub creation.

XSLT is handle to split xml/html file. Can we built Zip/ePUB file only
using XSLT file? I am using Saxon saxonhe9-2-0-3j.

Thanks
Byomokesh

Florent Georges

unread,
Dec 21, 2009, 5:20:05 AM12/21/09
to exp...@googlegroups.com
2009/12/21 Byomokesh Sahoo wrote:

Hi,

> I required only to create XSLT file for epub creation.

> XSLT is handle to split xml/html file. Can we built Zip/ePUB
> file only using XSLT file? I am using Saxon saxonhe9-2-0-3j.

Yes and no. No because there is nothing in the standard XPath
function library to deal with ZIP files. And yes because once
you have configured your processor correctly, you can use the
extensions defined in EXPath to deal with ZIP files, and then you
can use and create ZIP files by using only XSLT.

If you use Saxon 9.2 Home Edition, there is no way to call
Saxon from the command line and configure extension functions
(because net.sf.saxon.Transform does not provide any way to set
such info on the command line). The ZIP module for Saxon comes
with the appropriate Java code, but you have to plug it into
Saxon: either in Java, or by using the EXPath Packaging System.

I you use Saxon 9.1 or below, you can use the wrappers provided
in the XAR file. For instance, if you have in the same directory
the following files (from Saxon and from the ZIP XAR file):

- saxon9.jar
- expath-zip-saxon.jar
- expath-zip-saxon.xsl
- zip-list.xsl

the last one being:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:zip="http://www.expath.org/mod/zip"
version="2.0">

<xsl:import href="expath-zip-saxon.xsl"/>

<xsl:output indent="yes"/>

<xsl:template name="main">
<xsl:sequence select="
zip:entries('file:/c:/absolute/path/file.zip')"/>
</xsl:template>

</xsl:stylesheet>

Then you can execute it with:

java -cp "saxon9.jar;expath-zip-saxon.jar" \
net.sf.saxon.Transform -xsl:zip-list.xsl -it:main

Please tell us if something is not clear enough, or if you do
not succeed in running the above sample.

Byomokesh Sahoo

unread,
Dec 21, 2009, 5:37:06 AM12/21/09
to exp...@googlegroups.com
Hi Georges,

You recommended use below Saxon 9.1.

But Saxon 9.1.0.8 and Saxon 6.5.5 is available. which i will be install.

thanks
Byomokesh

Michael Kay

unread,
Dec 21, 2009, 5:40:40 AM12/21/09
to exp...@googlegroups.com

> You recommended use below Saxon 9.1.
>
> But Saxon 9.1.0.8 and Saxon 6.5.5 is available.

He's using "9.1" as a generic name for all maintenance releases in the 9.1
branch, of which 9.1.0.8 is the latest.

Byomokesh Sahoo

unread,
Dec 21, 2009, 6:03:29 AM12/21/09
to exp...@googlegroups.com
Hi,

Yes i run it. Its showing files name in the existing zip file. Please
find the below.

I have 4 html files in one directory including 2 sub directory.

d:\epub\
OPS (directory)
content.opf
style.css
toc.ncx
META-INF (directory)
container.xml
encryption.xml
1.html
2.html
3.html
4.html

I want built zip/epub file from d:\epub\

Output should be come d:\epub\sample.epub

Please tell what will be code and how i will execute.

Thanks
Byomokesh

Florent Georges

unread,
Dec 21, 2009, 6:40:58 AM12/21/09
to exp...@googlegroups.com
2009/12/21 Byomokesh Sahoo <sahoo.b...@gmail.com>:

> I have 4 html files in one directory including 2 sub directory.

> d:\epub\
> OPS (directory)
> content.opf
> style.css
> toc.ncx
> META-INF (directory)
> container.xml
> encryption.xml
> 1.html
> 2.html
> 3.html
> 4.html

> I want built zip/epub file from d:\epub\

> Output should be come d:\epub\sample.epub

> Please tell what will be code and how i will execute.

Replace the template main in the previous stylesheet with:

<xsl:template name="main">
<xsl:variable name="zip" as="element()">
<zip:file href="d:/epub/sample.epub">
<zip:dir name="OPS">
<zip:entry href="d:/epub/OPS/content.opf"
name="content.opf"/>
<zip:entry href="d:/epub/OPS/style.css"
name="style.css"/>
<zip:entry href="d:/epub/OPS/toc.ncx"
name="toc.ncx"/>
</zip:dir>
<zip:dir name="META-INF">
<zip:entry href="d:/epub/META-INF/container.xml"
name="container.xml"/>
<zip:entry href="d:/epub/META-INF/encryption.xml"
name="encryption.xml"/>
</zip:dir>
<zip:entry href="d:/epub/1.html" name="1.html"/>
<zip:entry href="d:/epub/2.html" name="2.html"/>
<zip:entry href="d:/epub/3.html" name="3.html"/>
<zip:entry href="d:/epub/4.html" name="4.html"/>
</zip:file>
</xsl:variable>
<xsl:sequence select="zip:zip-file($zip)"/>
</xsl:template>

and run it the same way.

That shows two minor issues with the zip file descriptor: it is
not convenient to add directories (recursively with all their
contents), and it is not convenient to add a file (or a dir) and
keep the same name. That will be changed in the spec, thanks for
pointing that out!

Of course, this extension was not designed for such a usage at
the first time. You seem to only create a ZIP file from existing
files. I am not sure whether using XSLT is really useful here.
Typically, it is if you generate any of the files using XSLT (for
instance the four HTML files).

Note that if you generate the HTML files but the rest of the
ZIP file is static, you can use what is called the "Compound
Document Template pattern" in the following paper:

http://www.balisage.net/Proceedings/vol3/html/Georges01/BalisageVol3-Georges01.html
http://www.balisage.net/Proceedings/vol3/author-pkg/Georges01/BalisageVol3-Georges01.html

It describes a way to get an existing ZIP file, and only change
some specific entries (here, you would then just add the HTML for
instance) ending up with a new ZIP file.

Byomokesh Sahoo

unread,
Dec 21, 2009, 7:09:55 AM12/21/09
to exp...@googlegroups.com
Thanks Georges.

I have replaced the "main" template and run in same command. But it
will showing Error

d:\saxonb9-1-0-8j>java -cp "saxon9.jar;expath-zip-saxon.jar" net.sf.saxon.Transf
orm -xsl:zip-list.xsl -it:main
Error
Exception in extension function java.lang.IllegalArgumentException: URI scheme
is not "file"
Transformation failed: Run-time errors were reported

> Of course, this extension was not designed for such a usage at
> the first time. You seem to only create a ZIP file from existing
> files. I am not sure whether using XSLT is really useful here.
> Typically, it is if you generate any of the files using XSLT (for
> instance the four HTML files).

I am not looking only create a Zip file using xslt. I am looking XSLT
Files to transform One XML Format to XHTML(based on .ePub format)
then create epub files.

XML --> XHTML --> .ePub

Please lookg the error report.

Thanks
Byomokesh

Florent Georges

unread,
Dec 21, 2009, 7:59:23 AM12/21/09
to exp...@googlegroups.com
2009/12/21 Byomokesh Sahoo wrote:

> Exception in extension function java.lang.IllegalArgumentException:
> URI scheme is not "file"

Yes, I've copied and pasted to quickly to make the URIs
absolute, and forgot to add the file: scheme, sorry. Just
replace each of:

href="d:/epub/..."

with:

href="file:/d:/epub/..."

Byomokesh Sahoo

unread,
Dec 21, 2009, 9:16:54 AM12/21/09
to exp...@googlegroups.com
Many Many Thanks Georges....

I think I have to mention file name after convert any single XML /
XHTML file. XSLT has no option to get the all file in that directory
without mention file name, directory name...?

It will be good if only give directory name, xslt will catch all
files, directory and built the zip/epub file.

Thanks
Byomokesh

Florent Georges

unread,
Dec 21, 2009, 11:57:38 AM12/21/09
to exp...@googlegroups.com
Byomokesh Sahoo wrote:

> It will be good if only give directory name, xslt will catch
> all files, directory and built the zip/epub file.

Yes. I have added the ability to add @src on a zip:dir
element, as well as not giving @name if there is @src (the name
is then by default the basename of @src). That allows you to
write instead:

<xsl:template name="main">
<xsl:variable name="zip" as="element()">

<zip:file href="sample.epub">
<zip:dir src="OPS"/>
<zip:dir src="META-INF"/>
<zip:entry src="1.html"/>
<zip:entry src="2.html"/>
<zip:entry src="3.html"/>
<zip:entry src="4.html"/>


</zip:file>
</xsl:variable>
<xsl:sequence select="zip:zip-file($zip)"/>
</xsl:template>

You can find it there:

http://www.fgeorges.org/tmp/expath-zip-saxon.jar

Please use it with caution, as this has not been tested
comprehensively. Please tell us if anything goes wrong.

Byomokesh Sahoo

unread,
Dec 22, 2009, 3:51:50 AM12/22/09
to exp...@googlegroups.com
Thanks George. It works fine.

Reply all
Reply to author
Forward
0 new messages