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 Sachin <xm...@yahoo.com> on 2004/05/19 01:11:58 UTC

Validating against DTD loaded in Cache.

Hi, 
�
I am unable to validate an XML document using its DTD
preloaded in Cache. However, validation is successful
if there exists an XSD for the same XML document in
cache. 
�
For example, for a document people.xml, validation is
successful if I preload people.xsd in cache and not if
I preload people.dtd. It complains with the error: 
"Cannot find the declaration of element 'people'. "
�
Here's the code I used to validate the xml. 

XMLGrammarCachingConfiguration xcg =new
XMLGrammarCachingConfiguration();
Grammar g1 =
xcg.parseGrammar(XMLGrammarDescription.XML_DTD,	
"file:///D://Schemas//people.dtd");
SAXParser parser = new SAXParser(xcg);

..... (Obtain InputStream for people.xml)
...
parser.setFeature("http://xml.org/sax/features/validation",true);
parser.setFeature("http://apache.org/xml/features/validation/schema",true);
					
parser.parse(inputstream);


Validation however works if I load people.xsd. What am
I missing here? 

I tried rewriting the above code using the Xerces
sample that uses XMLGrammarPreparser and
XMLGrammarPoolImpl. That gives me the same error (with
dtd's only and not xsd's). 

Thanks for any help, 
Sachin. 



	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

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