gdkinney_2
asked on
Exception using Java and XSLT to parse XHTML input file
I am using the following application:
import javax.xml.transform.Source ;
import javax.xml.transform.Transf ormer;
import javax.xml.transform.Transf ormerExcep tion;
import javax.xml.transform.Transf ormerFacto ry;
import javax.xml.transform.stream .StreamSou rce;
import javax.xml.transform.stream .StreamRes ult;
import java.io.*;
public class Transform {
/**
* Performs an XSLT transformation, sending the results
* to System.out.
*/
public static void main(String[] args) {
try{
if (args.length != 3) {
System.err.println(
"Usage: java Transform [xmlfile] [xsltfile]");
System.exit(1);
}
File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);
File xmlDest = new File(args[2]);
// JAXP reads data using the Source interface
Source xmlSource = new StreamSource(xmlFile);
//xmlSource.setSystemId("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" );
Source xsltSource = new StreamSource(xsltFile);
// the factory pattern supports different XSLT processors
TransformerFactory transFact =
TransformerFactory.newInst ance();
Transformer trans = transFact.newTransformer(x sltSource) ;
trans.transform(xmlSource, new StreamResult(xmlDest));
}
catch (TransformerException e2) {
System.out.println("Transf ormer Exception cause = " + e2);
}
catch (Exception e) {
System.out.println("Except ion ==== " + e);
}
}
}
to parse an XHTML input file with a DOCTYPE tag as the first tag as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I call the application from the command line as follows:
java Transform input.xml stylesheet.xsl output.xml
It throws the following exception:
ERROR: 'Connection timed out: connect'
ERROR: 'com.sun.org.apache.xml.in ternal.uti ls.Wrapped RuntimeExc eption: Connection timed out: connect'
Transformer Exception cause = javax.xml.transform.Transf ormerExcep tion: javax.xml.transform.Transf ormerExcep tion: com.sun.org.apache.xml.int ernal.util s.WrappedR untimeExce ption: Connection timed out: connect
Please help,
Dave
import javax.xml.transform.Source
import javax.xml.transform.Transf
import javax.xml.transform.Transf
import javax.xml.transform.Transf
import javax.xml.transform.stream
import javax.xml.transform.stream
import java.io.*;
public class Transform {
/**
* Performs an XSLT transformation, sending the results
* to System.out.
*/
public static void main(String[] args) {
try{
if (args.length != 3) {
System.err.println(
"Usage: java Transform [xmlfile] [xsltfile]");
System.exit(1);
}
File xmlFile = new File(args[0]);
File xsltFile = new File(args[1]);
File xmlDest = new File(args[2]);
// JAXP reads data using the Source interface
Source xmlSource = new StreamSource(xmlFile);
//xmlSource.setSystemId("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
Source xsltSource = new StreamSource(xsltFile);
// the factory pattern supports different XSLT processors
TransformerFactory transFact =
TransformerFactory.newInst
Transformer trans = transFact.newTransformer(x
trans.transform(xmlSource,
}
catch (TransformerException e2) {
System.out.println("Transf
}
catch (Exception e) {
System.out.println("Except
}
}
}
to parse an XHTML input file with a DOCTYPE tag as the first tag as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I call the application from the command line as follows:
java Transform input.xml stylesheet.xsl output.xml
It throws the following exception:
ERROR: 'Connection timed out: connect'
ERROR: 'com.sun.org.apache.xml.in
Transformer Exception cause = javax.xml.transform.Transf
Please help,
Dave
Make sure you are connected to the Internet when you try
ASKER
I am connected to the Internet. I can get to the web from my browser.
Hi,
xml/xslt file, If it starts with "http://", Xerces will try to open a HTTP connection to retrieve the content.
R.K
xml/xslt file, If it starts with "http://", Xerces will try to open a HTTP connection to retrieve the content.
R.K
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.