dcsimg
SAXparser and document validating
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Tomas_Feran
Posted On:   Friday, July 19, 2002 04:19 AM

I am using SAXparser from JAXP Api and having the following problem: xml file tomas.xml must conform DTD tomas.dtd, written like this: ... ... element foo is not defined in tomas.dtd my program TomasParser.java: public class TomasParser extends DefaultHandler { DefaultHandler defaultHandler = new TomasParser(); SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setValidating(true); //this should say to parser to validate the xml file according to its DTD (right?) SAXParser saxParser = factory.newSAXParser(); saxParser.parse("tomas.xml", def   More>>

I am using SAXparser from JAXP Api and having the following problem:



xml file tomas.xml must conform DTD tomas.dtd, written like this:




...

...




element foo is not defined in tomas.dtd



my program TomasParser.java:
public class TomasParser extends DefaultHandler {


DefaultHandler defaultHandler = new TomasParser();


SAXParserFactory factory = SAXParserFactory.newInstance();

factory.setValidating(true); //this should say to parser to validate the xml file according to its DTD (right?)

SAXParser saxParser = factory.newSAXParser();


saxParser.parse("tomas.xml", defaultHandler);

...

}



when the parser finds it should say that there is an error (right?), but it doesn't do that, it simple accepts the tag.



Where is the error?



Thank you very much

Tomas

   <<Less

Re: SAXparser and document validating

Posted By:   irfan_mansha  
Posted On:   Monday, July 22, 2002 11:00 PM

I don't think so there is any kind of error in ur application. Try to change path or location of ur dtd. There should be error if u have not defined element named foo.
About | Sitemap | Contact