Thanks for that great lead it worked perfectly!
I'm attachig some code for other searchers in the future:
System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
XSImplementation impl = (XSImplementation)
registry.getDOMImplementation("XS-Loader");
XSLoader schemaLoader = impl.createXSLoader( null );
XSModel xsModel = schemaLoader.loadURI( "file:///path-to/my-schema.xsd" );
XSTypeDefinition typeDefinition = xsModel.getTypeDefinition( "schema-type",
null );
ValidatedInfo info = validateString( "blah", (XSSimpleType) typeDefinition
); //validateString from xerces sameple code: simpletype.SimpleTypeUsage
From: Michael Glavassevich <[EMAIL PROTECTED]>
To: [email protected]
CC: "RefuX Zanzeebarr" <[EMAIL PROTECTED]>
Subject: Re: Validating data against a schema
Date: Mon, 26 Jun 2006 18:18:56 -0400
"RefuX Zanzeebarr" <[EMAIL PROTECTED]> wrote on 06/26/2006 05:02:27 PM:
> Hi there,
>
> I'm working on an integration project, and the project we're integrating
> with has a really nice schema and being the lazy person I am I would
like to
> leverage that schema as much as possible.
> One thing I would like to do is leverage the schema's validation rules
and
> use them in the UI (for validation). However to do this I need to
validate
> some data (whatever the user typed in) against a particular element (the
UI
> will know which schema element is realted to it) defined in the schema.
> I was wondering if there is a way to do this using XercesJ ?
I think org.apache.xerces.impl.dv [1] is what you're looking for. There's
a sample called simpletype.SimpleTypeUsage [2] which shows how to use the
interfaces/classes defined in this package.
> Any advice (even non-xerces :) much appreciated
>
> p.s. I know I can do this using EMF/SDO/XSD however our project is stuck
on
> JDK 1.3, so no nice there...
Xerces-J runs on JDK 1.3. Should still work on JDK 1.2 too, though I
haven't checked that in awhile.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
[1]
http://xerces.apache.org/xerces2-j/javadocs/xerces2/org/apache/xerces/impl/dv/package-summary.html
[2]
http://svn.apache.org/viewvc/xerces/java/trunk/samples/simpletype/SimpleTypeUsage.java?revision=320435&view=markup
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]