commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jason Vinson <vinson.li...@charter.net>
Subject Re: [Digester] XSD Support?
Date Thu, 17 Feb 2005 17:25:31 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

For the benefit of anyone who is looking for the answers to these
questions, here's what i've found.  Please correct any glaring errors
if you see them.

1.) AFAIK, XSD is supported in the digester if you use a non-Xerces
parser (i.e. Crimson)

2.) In order to setup validation with crimson in the digester, you
have to do something similar to the following:

~        SAXParserFactoryImpl crimsonFactory = new SAXParserFactoryImpl();
~        crimsonFactory.setValidating(true);
~        URL url =
Digester.class.getClassLoader().getResource("myFunSchema.xsd");
~        String schemaPath = url.toString();

~        Digester digester = new Digester(crimsonFactory.newSAXParser());
~        digester.setSchema(schemaPath);
~        digester.setErrorHandler(
~                  new ErrorHandler() {
~                      public void error(SAXParseException exception)
throws SAXException {
~                          throw new SAXExceptionSubclass("Error
validating XML - " + exception.getMessage());
~                      }
~                      public void fatalError(SAXParseException
exception) throws SAXException {
~                          throw new SAXExceptionSubclass("Fatal Error
validating XML - " + exception.getMessage());
~                      }
~                      public void warning(SAXParseException exception)
throws SAXException {
~                          throw new SAXExceptionSubclass("Warning
validating XML - " + exception.getMessage());
~                      }
~                  }
~                 );
~        // Add rules here

~        Object myObj = digester.parse(new StringReader(xml));

If anyone knows of a cleaner/more efficient way to do this, i'm all
ears  :)

Thanks,
Jason



Jason Vinson wrote:

| After reading some docs around the web, i found this:
|
| http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg31474.html
|
|
|
| And then found some other docs (not sure of the age) that mention
| Xerces having limited XML Schema support.  So I guess my questions
| are 1.) Do any of you use XSD's with your digesters, and 2.) how
| can i use something other than Xerces for my content handler in the
|  digester?
|
| Thanks for any pointers, Jason


- ---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCFNOLAQ71cZOfvEQRAo6BAJsF+8uC/gcY93hPxTHaQpPYXliuvQCePjzO
r2iPhXLVd4wBpHHdzfuYOh8=
=6BdI
-----END PGP SIGNATURE-----


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message