commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Jakarta-commons Wiki] Update of "Digester/FAQ" by SimonKitching
Date Sun, 31 Jul 2005 06:19:07 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-commons Wiki" for change notification.

The following page has been changed by SimonKitching:

The comment on the change is:
Add info on setting up schema validation for the input document

  More information on !EntityResolver behaviour can be found here:
+ == How can I validate the input document against a schema? ==
+ Unfortunately, validation of xml documents against schemas is not currently standardised,
+ ie the procedure for configuring this is parser-specific.
+ Some digester maintainers feel that Digester should provide the ability to turn on document
+ validation, and therefore the following methods have been defined on the Digester class:
+ {{{
+   Digester.setValidating
+   Digester.setSchema
+   Digester.setSchemaLanguage
+ }}}
+ If you get validation working using these, then please document the procedure here. In particular,
+ you may wish to look at the source for the !ParserFeatureSetterFactory and the classes in
+ org.apache.commons.digester.parser package.
+ However other digester maintainers feel that as this functionality is complex to set up
+ not currently portable the best approach is for users to configure the parser first, then
+ pass the parser to the Digester object. This makes it possible for users to write test code
+ to get the document reading and validating working first without involving digester. This
+ approach will result in something like the following:
+ {{{
+ SAXParserFactory f = SAXParserFactory.newInstance();
+ f.setValidating(true);
+ SAXParser p = f.newSAXParser();
+ p.setErrorHandler(new MyErrorHandler());
+ // do parser-specific stuff to set up schema validation here
+ // here you can test whether you have got the schema validation correctly set up by
+ // just trying to parse the document. once that is working correctly, add the code
+ // below to hook a digester instance up to that parser...
+ Digester d = new Digester(p);
+ p.setContentHandler(d);
+ p.setDTDHandler(d); // optional
+ p.setEntityResolver(d); // optional
+ // add digester rules here
+ d.parse(...);
+ }}}

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message