You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by DeWayne <de...@boeing.com> on 2009/10/30 01:24:54 UTC

How to resolve UnknownHostException with Xerces-J API?

I'm trying to parse an xml file with entities like the one below. I'm sitting
behind a firewall as well and I'm using Xerces-j-2.9.1 to implement the
SAXParser. I need the Parser to resolve the entity. When I run the app, I
get the java exception java.net.UnknowHostException: www.w3.org. Code and
command line args given below.

entity requiring navigation of the internet to resolve it
===========================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mpd SYSTEM "mpboe03.dtd" [
<!ENTITY % isobox PUBLIC "-//W3C//ENTITIES Box and Line Drawing//EN//XML"
"http://www.w3.org/2003/entities/2007/isobox.ent" >
 %isobox;

code snippet to setup the parser
========================

try {
	parser =
XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
	parser.setErrorHandler(this);

	// Turn on validation
	parser.setFeature("http://xml.org/sax/features/validation", true);
      ...}

//invoke the parser along with the schema/dtd to use and the xml file to
parse
================
try {
	parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
schema.getAbsolutePath());
	parser.parse(xmlfile2Parse.getAbsolutePath());
}

//command line options to navigate the firewall - specify the proxy and port
======================================
java -Dhttp.proxyHost=\"www-use-proxys.web.foo.com\"
-Dhttp.proxyPort=\"98760\" -classpath .:xercesImpl.jar myApp

-- 
View this message in context: http://www.nabble.com/How-to-resolve-UnknownHostException-with-Xerces-J-API--tp26123150p26123150.html
Sent from the Xerces - J - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: How to resolve UnknownHostException with Xerces-J API?

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Yes. Using a resolver is generally a good idea, in particular one which
hooks up to an XML catalog [1]. The W3C gets hammered with requests for
DTDs [2] (and other entities) on its site every day, so on top of all the
other reasons why it's good to use catalogs, it will prevent your IP from
getting blacklisted for hitting their site one too many times for the same
resource.

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-xcatalogs.html
[2] http://www.w3.org/blog/systeam/2008/02/08/w3c_s_excessive_dtd_traffic

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Benson Margulies <bi...@gmail.com> wrote on 10/29/2009 10:00:40 PM:

> You may need to set a resolver and read these things in your own code.

> On Thu, Oct 29, 2009 at 8:24 PM, DeWayne <dewayne.c.dantzler@boeing.com
> > wrote:
>
> I'm trying to parse an xml file with entities like the one below. I'm
sitting
> behind a firewall as well and I'm using Xerces-j-2.9.1 to implement the
> SAXParser. I need the Parser to resolve the entity. When I run the app, I
> get the java exception java.net.UnknowHostException: www.w3.org. Code and
> command line args given below.
>
> entity requiring navigation of the internet to resolve it
> ===========================
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE mpd SYSTEM "mpboe03.dtd" [
> <!ENTITY % isobox PUBLIC "-//W3C//ENTITIES Box and Line Drawing//EN//XML"
> "http://www.w3.org/2003/entities/2007/isobox.ent" >
>  %isobox;
>
> code snippet to setup the parser
> ========================
>
> try {
>        parser =
> XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
>        parser.setErrorHandler(this);
>
>        // Turn on validation
>        parser.setFeature("http://xml.org/sax/features/validation", true);
>      ...}
>
> //invoke the parser along with the schema/dtd to use and the xml file to
> parse
> ================
> try {
>        parser.setProperty("http://java.sun.
> com/xml/jaxp/properties/schemaSource",
> schema.getAbsolutePath());
>        parser.parse(xmlfile2Parse.getAbsolutePath());
> }
>
> //command line options to navigate the firewall - specify the proxy and
port
> ======================================
> java -Dhttp.proxyHost=\"www-use-proxys.web.foo.com\"
> -Dhttp.proxyPort=\"98760\" -classpath .:xercesImpl.jar myApp
>
> --
> View this message in context: http://www.nabble.com/How-to-resolve-
> UnknownHostException-with-Xerces-J-API--tp26123150p26123150.html
> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org

Re: How to resolve UnknownHostException with Xerces-J API?

Posted by Benson Margulies <bi...@gmail.com>.
You may need to set a resolver and read these things in your own code.

On Thu, Oct 29, 2009 at 8:24 PM, DeWayne <de...@boeing.com>wrote:

>
> I'm trying to parse an xml file with entities like the one below. I'm
> sitting
> behind a firewall as well and I'm using Xerces-j-2.9.1 to implement the
> SAXParser. I need the Parser to resolve the entity. When I run the app, I
> get the java exception java.net.UnknowHostException: www.w3.org. Code and
> command line args given below.
>
> entity requiring navigation of the internet to resolve it
> ===========================
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE mpd SYSTEM "mpboe03.dtd" [
> <!ENTITY % isobox PUBLIC "-//W3C//ENTITIES Box and Line Drawing//EN//XML"
> "http://www.w3.org/2003/entities/2007/isobox.ent" >
>  %isobox;
>
> code snippet to setup the parser
> ========================
>
> try {
>        parser =
> XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
>        parser.setErrorHandler(this);
>
>        // Turn on validation
>        parser.setFeature("http://xml.org/sax/features/validation", true);
>      ...}
>
> //invoke the parser along with the schema/dtd to use and the xml file to
> parse
> ================
> try {
>        parser.setProperty("
> http://java.sun.com/xml/jaxp/properties/schemaSource",
> schema.getAbsolutePath());
>        parser.parse(xmlfile2Parse.getAbsolutePath());
> }
>
> //command line options to navigate the firewall - specify the proxy and
> port
> ======================================
> java -Dhttp.proxyHost=\"www-use-proxys.web.foo.com\"
> -Dhttp.proxyPort=\"98760\" -classpath .:xercesImpl.jar myApp
>
> --
> View this message in context:
> http://www.nabble.com/How-to-resolve-UnknownHostException-with-Xerces-J-API--tp26123150p26123150.html
> Sent from the Xerces - J - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
>
>