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:
http://wiki.apache.org/jakarta-commons/Digester/FAQ

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:
    http://xml.apache.org/commons/components/resolver/resolver-article.html
  
+ 
+ == 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 the
+ org.apache.commons.digester.parser package.
+ 
+ However other digester maintainers feel that as this functionality is complex 
to set up and
+ 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to