Java command line failure

Here should go questions about transforming XML with XSLT and FOP.
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Java command line failure

Post by sderrick »

This is not really a question about Oxygen but about moving a stylesheet developed in Oxygen into a production environment.

I have a very simple style sheet to extract the text from a html document.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
version="2.0">

<xsl:output method="text" encoding="utf-8"/>

<xsl:template match="html:span[@class='line_number' or @class='mobi-page-number']"/>
<xsl:template match="html:span[@class='indent']"/>
</xsl:stylesheet>
This runs fine in Oxygen.

But when I try to run it on the command line using a saxon parser this is the result?

Code: Select all


scott@:~/workspace/books_changes2$  java -jar lib/saxonHE-9.3.0.5.jar -o:build/etemp/html_1.txt -s:build/html/sh-tei.html -xsl:xslt/htm2text.xsl
Error
java.net.SocketException: Unexpected end of file from server
Transformation failed: Run-time errors were reported
scott@:~/workspace/books_changes2$
Why would I be getting a socket exception?

Scott
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: Java command line failure

Post by Dan »

My guess is that your XML input file uses a DTD that cannot be accessed by the XSLT processor. This happens usually when you are using an HTTP proxy server to connect to Internet.

You should try using a catalog resolver, like this (place all the arguments on a single line):

Code: Select all


java 
-Dxml.catalog.files=[OXYGEN_INSTALL_DIR]\frameworks\xhtml\dtd\xhtmlcatalog.xml
-cp [OXYGEN_INSTALL_DIR]lib\resolver.jar;lib\saxonHE-9.3.0.5.jar
net.sf.saxon.Transform
-r:org.apache.xml.resolver.tools.CatalogResolver
-x:org.apache.xml.resolver.tools.ResolvingXMLReader
-y:org.apache.xml.resolver.tools.ResolvingXMLReader
-s:build/html/sh-tei.html
-xsl:xslt/htm2text.xsl
-o:build/etemp/html_1.txt
I recommend downloading the Apache Resolver jar (xml-commons-resolver-1.2.zip, from http://xml.apache.org/) and placing it into your project. You can copy the XHTML catalog files and DTDs from the Oxygen installation.

Regards,
Dan
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

thanks Dan I'll try that!
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

Dan, I'm sorry to say that didn't work. I used the resolver.jar included in Oxygen and ran this

Code: Select all


java 
-Dxml.catalog.files=/opt/Oxygen\ XML\ Editor\ 12/frameworks/xhtml/dtd/xhtmlcatalog.xml
-cp /opt/Oxygen\ XML\ Editor\ 12/lib/resolver.jar:lib/saxonHE-9.3.0.5.jar
net.sf.saxon.Transform
-r:org.apache.xml.resolver.tools.CatalogResolver
-x:org.apache.xml.resolver.tools.ResolvingXMLReader
-y:org.apache.xml.resolver.tools.ResolvingXMLReader
-s:build/html/sh-tei.html
-xsl:xslt/htm2text.xsl
-o:build/etemp/html_1.txt
the error was the same

Code: Select all


Error 
java.net.SocketException: Unexpected end of file from server
Transformation failed: Run-time errors were reported
I then downloaded the resolver.jar from Apache and ran this

Code: Select all


java 
-Dxml.catalog.files=/opt/Oxygen\ XML\ Editor\ 12/frameworks/xhtml/dtd/xhtmlcatalog.xml
-cp lib/resolver.jar:lib/saxonHE-9.3.0.5.jar
net.sf.saxon.Transform
-r:org.apache.xml.resolver.tools.CatalogResolver
-x:org.apache.xml.resolver.tools.ResolvingXMLReader
-y:org.apache.xml.resolver.tools.ResolvingXMLReader
-s:build/html/sh-tei.html
-xsl:xslt/htm2text.xsl
-o:build/etemp/html_1.txt
same error?
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

Here's the verbose output from Java, I truncated it but its still long!!

Code: Select all


[Loaded net.sf.saxon.tinytree.TinyNodeImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyParentNodeImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyDocumentImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyElementImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyTextImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.WhitespaceTextImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyCommentImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.TinyProcInstImpl from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded net.sf.saxon.tinytree.LargeStringBuffer from file:/home/scott/workspace/books_changes2/lib/saxonHE-9.3.0.5.jar]
[Loaded java.lang.ArrayIndexOutOfBoundsException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.io.ASCIIReader from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.validation.EntityState from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.xni.grammars.Grammar from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.dtd.models.ContentModelValidator from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar$QNameHashtable from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.dtd.XMLContentSpec from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDriver from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.xml.internal.stream.StaxXMLInputSource from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.Handler from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.HttpURLConnection from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.Logger from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.Handler from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.Level from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.beans.PropertyChangeSupport from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$LogNode from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LoggingPermission from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$Cleaner from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.lang.ApplicationShutdownHooks from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.lang.ApplicationShutdownHooks$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.lang.Shutdown from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.lang.Shutdown$Lock from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.IdentityHashMap from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$RootLogger from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.Hashtable$Enumerator from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.EventObject from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.beans.PropertyChangeEvent from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.logging.LogManager$3 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.security.action.GetIntegerAction from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.AuthCacheValue from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.AuthenticationInfo from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.NTLMAuthentication from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.AuthCache from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.AuthCacheImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.NTLMAuthenticationCallback from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.NTLMAuthenticationCallback$DefaultNTLMAuthenticationCallback from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.NTLMAuthentication$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.HttpURLConnection$TunnelState from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.HttpURLConnection$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.CookieHandler from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.HttpURLConnection$3 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.ResponseCache from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.util.HTTPInputSource from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.protocol.http.HttpURLConnection$5 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.ProxySelector from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.DefaultProxySelector from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.DefaultProxySelector$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.NetProperties from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.NetProperties$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.DefaultProxySelector$NonProxyInfo from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.DefaultProxySelector$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.DefaultProxySelector$3 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Proxy from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Proxy$Type from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.NetworkClient from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.HttpClient from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.NetworkClient$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.KeepAliveCache from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.HttpClient$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.HttpClient$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.KeepAliveKey from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.www.http.HttpClient$3 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Socket from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocksConsts from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketOptions from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.PlainSocketImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocksSocketImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.security.action.LoadLibraryAction from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketAddress from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetSocketAddress from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddress from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddress$Cache from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddress$Cache$Type from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddressImplFactory from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddressImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Inet6AddressImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.spi.nameservice.NameService from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddress$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Inet4AddressImpl from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Inet4Address from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.InetAddressCachePolicy from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.InetAddressCachePolicy$1 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded sun.net.InetAddressCachePolicy$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.Queue from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.Deque from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.AbstractSequentialList from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.LinkedList from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.LinkedList$Entry from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.LinkedHashMap$KeyIterator from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.util.LinkedList$ListItr from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.InetAddress$CacheEntry from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Inet6Address from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocksSocketImpl$5 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Socket$3 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketOutputStream from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.Socket$2 from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketInputStream from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.io.InterruptedIOException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.net.SocketTimeoutException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded java.io.EOFException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
[Loaded com.sun.org.apache.xerces.internal.xni.parser.XMLParseException from /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar]
Error
java.net.SocketException: Unexpected end of file from server
Transformation failed: Run-time errors were reported
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

:shock: This is killing me!

Why would a script run fine in Oxygen and not on the command line in the same environment? Same version of Java same version of saxon parser!!!

Scott
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

It has been suggested that Oxygen is using a cached copy of the html dtd?

xmlns:html="http://www.w3.org/1999/html"

and when I run saxon on the command line it's trying to get it using the "http://www.w3.org/1999/html" address and not getting it?

Is that possible?

If so where are the dtd's and how do I tell saxon on the command line to use the local one?

Scott
sderrick
Posts: 269
Joined: Sat Jul 10, 2010 4:03 pm

Re: Java command line failure

Post by sderrick »

Dan you were right, almost!
sderrick wrote:Dan, I'm sorry to say that didn't work. I used the resolver.jar included in Oxygen and ran this

Code: Select all


java 
-Dxml.catalog.files=/opt/Oxygen\ XML\ Editor\ 12/frameworks/xhtml/dtd/xhtmlcatalog.xml
-cp /opt/Oxygen\ XML\ Editor\ 12/lib/resolver.jar:lib/saxonHE-9.3.0.5.jar
net.sf.saxon.Transform
-r:org.apache.xml.resolver.tools.CatalogResolver
-x:org.apache.xml.resolver.tools.ResolvingXMLReader
-y:org.apache.xml.resolver.tools.ResolvingXMLReader
-s:build/html/sh-tei.html
-xsl:xslt/htm2text.xsl
-o:build/etemp/html_1.txt
I changed

-Dxml.catalog.files=/opt/Oxygen\ XML\ Editor\ 12/frameworks/xhtml/dtd/xhtmlcatalog.xml

to

-Dxml.catalog.files=/opt/Oxygen\ XML\ Editor\ 12/frameworks/xhtml11/dtd/xhtmlcatalog.xml

and it worked!

mucho thanks...
Post Reply