XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] How to open XML file that reference entity resolver (DTD)

Hi Liam,
 
That is the bizarre thing is that this enitity resolver issue would not come up if I was to convert the original City.xhtml file to City.xml with TagSoup parser using the following codes:
 
a.  BufferedReader cityIncomingbrHtml = new BufferedReader(new FileReader("C:\City.xhtml"));b.  SAXBuilder saxBuilder = new SAXBuilder("org.ccil.cowan.tagsoup.Parser", false);
c.  cityJDOMDocument = saxBuilder.build(cityI
d.  cityOutXml = new BufferedWriter(new FileWriter(C:\City.xml));ncomingbrHtml);  XPath cityXPath = XPath.newInstance("/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a/@title");
h.  java.util.List cityList = cityXPath.selectNodes(cityJDOMDocument);
i.  Iterator city_iterator = cityList.iterator();
j.  while (city_iterator.hasNext()) { 
k.     city_content = ((org.jdom.Attribute)city_iterator.next()).getValue();
l.      if (city_content.length() != 0) {
m.        System.out.println("City Url:" + city_content.toString()); }
n.   }
cityJDOMDocument);
7. Iterator city_iterator = cityList.iterator();
8. while (city_iterator.hasNext()) { 
9. city_content = ((org.jdom.Attribute)city_iterator.next()).getValue();
10. if (city_content.length() != 0) {
11. System.out.println("City Url:" + city_content.toString()); }
12. }

e.
f.  outputter.output(cityJDOMDocument, cityOutXml); 
 
g.
 
Yet it would errored out when reading the converted C:\City.xml directly as covered earlier and again as follows: 
 
1. BufferedReader incomingbrXml = new BufferedReader(new FileReader("C:\City.xml"));
2. SAXBuilder saxBuilder = new SAXBuilder(false);
3. Document jdomXmlDocument = saxBuilder.build(incomingbrXml);
4. String city_content = null;
5. XPath cityXPath = XPath.newInstance("/ns:html/ns:body/ns:div[@id='content']/ns:table[@class='sresults']/ns:tr/ns:td/ns:a/@title");
6. java.util.List cityList = cityXPath.selectNodes(
 
Looks like it is the default Sax parser possibly via JAXP that does not come with the XHTML DTDs and with an XML catalog set up to use them instead of going to www.w3.org each time.
I am still waying through the references to use XML Catalog but it doesn't appears to provide every facets to a Java solution. It would great if you could provide some example of how everything are interconnected together.
 
The 3rd option you have suggested by turning off validation with SAXBuilder.setValidating(false) does not prevent the process of resolving DTD document.
 
Thanks in advance,
Jack
 
 
----- Original Message ----
From: Liam R E Quin <liam@w3.org>
To: xml-dev@lists.xml.org
Sent: Tue, 29 June, 2010 3:40:36 AM
Subject: Re: [xml-dev] How to open XML file that reference entity resolver (DTD)


First, please file a bug against whatever software you are using -
it should come with the XHTML DTDs and with an XML catalog set
up to use them instead of going to www.w3.org each time.

Second, use an XML Catalog for this. You'll need the DTD for
XML processing if you try to use entities like &eacute; that
are defined in it.

Third, you could turn off valdation, probably with something like
SAXBuilder.setValidating(false);

Or, set the Java property http://xml.org/sax/features/validation
to false.


Liam

XMLOutputter outputter = new XMLOutputter();


----- Original Message ----
From: Liam R E Quin <liam@w3.org>
To: xml-dev@lists.xml.org
Sent: Tue, 29 June, 2010 3:40:36 AM
Subject: Re: [xml-dev] How to open XML file that reference entity resolver (DTD)


First, please file a bug against whatever software you are using -
it should come with the XHTML DTDs and with an XML catalog set
up to use them instead of going to www.w3.org each time.

Second, use an XML Catalog for this. You'll need the DTD for
XML processing if you try to use entities like &eacute; that
are defined in it.

Third, you could turn off valdation, probably with something like
SAXBuilder.setValidating(false);

Or, set the Java property http://xml.org/sax/features/validation
to false.


Liam


-- 
Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/
Ankh: irc.sorcery.net irc.gnome.org www.advogato.org


_______________________________________________________________________

XML-DEV is a publicly archived, unmoderated list hosted by OASIS
to support XML implementation and development. To minimize
spam in the archives, you must subscribe before posting.

[Un]Subscribe/change address: http://www.oasis-open.org/mlmanage/
Or unsubscribe: xml-dev-unsubscribe@lists.xml.org
subscribe: xml-dev-subscribe@lists.xml.org
List archive: http://lists.xml.org/archives/xml-dev/
List Guidelines: http://www.oasis-open.org/maillists/guidelines.php






[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS