<?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://isocra.com/2006/05/making-xerces-ignore-a-dtd/feed/" rel="self" type="application/rss+xml" />
	<link>http://isocra.com/2006/05/making-xerces-ignore-a-dtd/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=making-xerces-ignore-a-dtd</link>
	<description>Thoughts and tutorials on web design, Java, Javascript and project management</description>
	<lastBuildDate>Thu, 16 May 2013 13:23:35 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
	<item>
		<title>By: Groovy XmlSlurper for HTML parsing</title>
		<link>http://isocra.com/2006/05/making-xerces-ignore-a-dtd/comment-page-1/#comment-3497</link>
		<dc:creator>Groovy XmlSlurper for HTML parsing</dc:creator>
		<pubDate>Tue, 21 Aug 2012 10:01:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.isocra.com/new/2006/05/making-xerces-ignore-a-dtd/#comment-3497</guid>
		<description><![CDATA[[...] don&#8217;t try to build your own SAXParser respectivly SAXParserFactory with special features that doesn&#8217;t load DTDs, has a dummy entity-resolver, is not validating  or ignores missing end-tags. Wrong direction [...]]]></description>
		<content:encoded><![CDATA[<p>[...] don&#8217;t try to build your own SAXParser respectivly SAXParserFactory with special features that doesn&#8217;t load DTDs, has a dummy entity-resolver, is not validating  or ignores missing end-tags. Wrong direction [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Glenn</title>
		<link>http://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><![CDATA[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://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><![CDATA[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://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><![CDATA[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://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><![CDATA[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://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><![CDATA[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://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><![CDATA[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://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><![CDATA[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://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><![CDATA[awesome!]]></description>
		<content:encoded><![CDATA[<p>awesome!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mansi</title>
		<link>http://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><![CDATA[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://isocra.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> &#8230;thnx a ton</p>
]]></content:encoded>
	</item>
</channel>
</rss>
