Hi Kohsuke,

The 2nd way you tried is theoretically the preferred approach; that's the
whole point of XMLSchemaLoader in fact.  The fact it doesn't work is a
clear bug...  Another bug was reported this morning, and I'll look at both
as soon as I get time (before end of week with any luck).

Thanks for reporting this and if you get any insights let me know.  :-)

Cheers,
Neil
Neil Graham
XML Parser Development
IBM Toronto Lab
Phone:  905-413-3519, T/L 969-3519
E-mail:  [EMAIL PROTECTED]




                                                                                   
                    Kohsuke Kawaguchi                                              
                    <Kohsuke.Kawaguch       To:     [EMAIL PROTECTED]    
                    [EMAIL PROTECTED]>              cc:                                    
                                            Subject:     [Schema CM API] can't     
                    06/05/2002 03:21         load schema                           
                    PM                                                             
                    Please respond to                                              
                    xerces-j-dev                                                   
                                                                                   
                                                                                   




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]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to