I'm trying to build a XSModel from a schema, but I couldn't make it work.
I tried three ways,
> private static SchemaGrammar load( String source ) {
> XSDHandler handler = new XSDHandler(new XSGrammarBucket());
>
> // initialize the schema compiler.
> handler.reset(
> null, // new XMLErrorReporter(),
> new XMLEntityResolverImpl(),
> new SymbolTable(),
> new XMLGrammarPoolImpl());
>
> // prepare XSDDescription.
> XSDDescription xdecl = new XSDDescription();
> xdecl.setContextType( xdecl.CONTEXT_PREPARSE );
>
> xdecl.setLiteralSystemId(source);
> xdecl.setExpandedSystemId(source);
> xdecl.setLocationHints( new String[]{source} );
>
> SchemaGrammar schema =
> handler.parseSchema(
> new XMLInputSource(null,source,source),
> xdecl,new Hashtable());
>
> return schema;
> }
When I load a schema with this method, it causes error "src-resolve.4".
Apparently, it fails to access to components defined in imported schemas.
> private static SchemaGrammar load2( String source ) throws Exception {
> XMLSchemaLoader loader = new XMLSchemaLoader();
> loader.setErrorHandler(new ErrorHandlerWrapper(
> null));
> loader.reset();
>
> return (SchemaGrammar)loader.loadGrammar(
> new XMLInputSource(null,source,source));
> }
This also causes the same error.
> private static XSModel load3(String source) throws Exception {
> DOMASBuilder b = new DOMASBuilderImpl();
> return as2xsModel(b.parseASURI(source));
> }
>
> private static XSModel as2xsModel(ASModel asmodel) {
> ASModelImpl model = (ASModelImpl)asmodel;
> Vector models = model.getInternalASModels();
> SchemaGrammar[] grammars = new SchemaGrammar[models.size()];
> for (int i = 0; i < models.size(); i++)
> grammars[i] = ((ASModelImpl)models.elementAt(i)).getGrammar();
> return new XSModelImpl(grammars);
> }
And finally, this fails because entityResolver of XMLSchemaLoader is not
set.
What is the proper way to build XSModel?
Any help would be greatly appreciated.
regards,
--
Kohsuke KAWAGUCHI
Sun Microsystems [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]