<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Making Xerces ignore a DTD</title>
	<atom:link href="http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/</link>
	<description>Thoughts and tutorials on web design, Java, Javascript and project management</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:33:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Glenn</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-2931</link>
		<dc:creator>Glenn</dc:creator>
		<pubDate>Mon, 23 Jan 2012 20:12:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-2931</guid>
		<description>I should have added... if you want to validate, bundle the DTD in your JAR, in the same folder as your parsing utility class.  That way, you know exactly where it is, and after all, it is a class resource in this context.  Then have your utility class implement EntityResolver thus:

@Override
public InputSource resolveEntity(String publicId, String systemId) {
   return new InputSource(MyUtilityClass.class.getResourceAsStream(&quot;logger.dtd&quot;));
}

And set the entity resolver of the parser to the instance of your utility class (eg, &quot;this&quot;).</description>
		<content:encoded><![CDATA[<p>I should have added&#8230; if you want to validate, bundle the DTD in your JAR, in the same folder as your parsing utility class.  That way, you know exactly where it is, and after all, it is a class resource in this context.  Then have your utility class implement EntityResolver thus:</p>
<p>@Override<br />
public InputSource resolveEntity(String publicId, String systemId) {<br />
   return new InputSource(MyUtilityClass.class.getResourceAsStream(&#8220;logger.dtd&#8221;));<br />
}</p>
<p>And set the entity resolver of the parser to the instance of your utility class (eg, &#8220;this&#8221;).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-2930</link>
		<dc:creator>Glenn</dc:creator>
		<pubDate>Mon, 23 Jan 2012 19:34:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-2930</guid>
		<description>Pass the parser an EntityResolver that returns an empty DTD:
&lt;pre&gt;
final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(false);
final SAXParser saxParser = saxParserFactory.newSAXParser();
final XMLReader parser = saxParser.getXMLReader();

parser.setEntityResolver(new EntityResolver(){
	public InputSource resolveEntity(String publicId, String systemId) {
		return new InputSource(new ByteArrayInputStream(new byte[]{}));
	}
});
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Pass the parser an EntityResolver that returns an empty DTD:</p>
<pre>
final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(false);
final SAXParser saxParser = saxParserFactory.newSAXParser();
final XMLReader parser = saxParser.getXMLReader();

parser.setEntityResolver(new EntityResolver(){
	public InputSource resolveEntity(String publicId, String systemId) {
		return new InputSource(new ByteArrayInputStream(new byte[]{}));
	}
});
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: DenisH</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1709</link>
		<dc:creator>DenisH</dc:creator>
		<pubDate>Thu, 01 Dec 2011 11:20:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1709</guid>
		<description>Hi smac, what exactly do you mean when you say &quot;where did you add this&quot;? 

To make Xerces ignore the DTD, just after you&#039;ve created the XMLReader (assigned to &lt;code&gt;parser&lt;/code&gt; in my example above), you set the two features shown and then it ignores the DTD (but obviously this means that it won&#039;t check to ensure that the XML conforms to it). 

That&#039;s all you have to do.</description>
		<content:encoded><![CDATA[<p>Hi smac, what exactly do you mean when you say &#8220;where did you add this&#8221;? </p>
<p>To make Xerces ignore the DTD, just after you&#8217;ve created the XMLReader (assigned to <code>parser</code> in my example above), you set the two features shown and then it ignores the DTD (but obviously this means that it won&#8217;t check to ensure that the XML conforms to it). </p>
<p>That&#8217;s all you have to do.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: smac</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1708</link>
		<dc:creator>smac</dc:creator>
		<pubDate>Wed, 30 Nov 2011 20:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1708</guid>
		<description>Where did you add this? Sorry, total newb question, but I&#039;ve needed to do this for years, and I&#039;ve no one to walk me through it.</description>
		<content:encoded><![CDATA[<p>Where did you add this? Sorry, total newb question, but I&#8217;ve needed to do this for years, and I&#8217;ve no one to walk me through it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hoschi</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1217</link>
		<dc:creator>Hoschi</dc:creator>
		<pubDate>Wed, 15 Sep 2010 08:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1217</guid>
		<description>Thx alot.
it was quite useful for me.
I searched the hell for a solution and this works quite fine,
But...are there any disadvantages which I&#039;m getting with this solution?
XML validation still persists or is switched off as well?</description>
		<content:encoded><![CDATA[<p>Thx alot.<br />
it was quite useful for me.<br />
I searched the hell for a solution and this works quite fine,<br />
But&#8230;are there any disadvantages which I&#8217;m getting with this solution?<br />
XML validation still persists or is switched off as well?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Purrfect</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1120</link>
		<dc:creator>Purrfect</dc:creator>
		<pubDate>Wed, 12 May 2010 17:38:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1120</guid>
		<description>You are a star, scholar and gentleman. I was at the point of doing some string manipulation to get rid of the frigging DOCTYPE !</description>
		<content:encoded><![CDATA[<p>You are a star, scholar and gentleman. I was at the point of doing some string manipulation to get rid of the frigging DOCTYPE !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NS</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1088</link>
		<dc:creator>NS</dc:creator>
		<pubDate>Mon, 19 Apr 2010 16:53:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1088</guid>
		<description>Yeah, even I spent quite a lot of time wandering on different sites before I came across this. Works perfectly. Thanks.</description>
		<content:encoded><![CDATA[<p>Yeah, even I spent quite a lot of time wandering on different sites before I came across this. Works perfectly. Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sumit</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-1059</link>
		<dc:creator>sumit</dc:creator>
		<pubDate>Wed, 31 Mar 2010 16:22:59 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-1059</guid>
		<description>awesome!</description>
		<content:encoded><![CDATA[<p>awesome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mansi</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-984</link>
		<dc:creator>Mansi</dc:creator>
		<pubDate>Wed, 20 Jan 2010 13:45:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-984</guid>
		<description>Hi...
thanx for ur reply ..i was struggling with this thing for the past two days ... :(...thnx a ton</description>
		<content:encoded><![CDATA[<p>Hi&#8230;<br />
thanx for ur reply ..i was struggling with this thing for the past two days &#8230; <img src='http://www.isocra.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> &#8230;thnx a ton</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://www.isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-981</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Thu, 14 Jan 2010 13:06:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-981</guid>
		<description>Hello forum &amp; poster of this solution.
Been reading, trying various things and searching the web for two days before coming across this!

Thanks it worked a treat.
Java newbie.</description>
		<content:encoded><![CDATA[<p>Hello forum &amp; poster of this solution.<br />
Been reading, trying various things and searching the web for two days before coming across this!</p>
<p>Thanks it worked a treat.<br />
Java newbie.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

