Hi Sandy,

> I agree. But we want to access all the types in a consistent way, no matter
> whether it's built-in or not:
> 
> SchemaGrammar grammar = grammarResolver.getGrammar(uri);
> XSType type = grammar.getTypeDecl(typeName);
> 
> Instead of:
> 
> if (uri == schemaNamespace)
>   simpleTypeactory.get...(...)
> else
>   // get it from a grammar matching the namespace
> So in my opinion, the built-in types should be in a separate grammar, which
> corresponds to the schema namespace.

sandy, did u see my second mail in which i proposed "SchemaNSGrammar"
extending "SchemaGrammar". I am posting it again with some modifications
        

class SchemaNSGrammar extends SchemaGrammar{

//private Constructor

//we can make sure in this method that it's initalized once.
public static SchemaGrammar initializeBuiltInTypes(){

SchemaNSGrammar schemaNSGrammar = new SchemaNSGrammar();
......
......
XSSimpleTypeDecl stringST = 
SimpleTypeFactoryImpl.getBuiltInType(SchemaSymbols.ATTVAL_STRING);
schemaNSGrammar.addTypeDecl(stringST,true);

......
......
return schemaNSGrammar;

} //initializeBuiltInTypes()


}//class SchemaNSGrammar

now we have separate grammar for built-in types which corresponds to schema
Namespace and can be put in the grammar resolver like as we are doing
now in the constructor of XSGrammarResolver, 
        
XSGrammarResolver() {
        putGrammar(SchemaSymbols.URI_SCHEMAFORSCHEMA, 
SchemaNSGrammar.intializeBuiltIntypes());
    }
    
    now if we actually want to access any type, like 

SchemaGrammar grammar = grammarResolver.getGrammar(uri);
XSType type = grammar.getTypeDecl(typeName);

we dont need to know if it's built in type or not.

    
> If you can achieve this, then having a
> separate class/interface for built-in types would be a good idea.
> 
> > i was thinking do we need to store the information about these built-in
> > datatypes ,if validation is turned off ? As of now it will always be done
> as a
> > part of static initialization.
> 
> And putting them as static is for the same reason: other classes in the
> schema package can access the built-in types directly. I hope you can do a
> search for "SG_SchemaNS" in the v2 folder. If you can come up with ideas of
> accessing the built-in types from those places, I'm ok of putting them as
> non-static.

i saw "SG_SchemaNS" being used for accessing built-in types directly. I
feel we can have,as u said, our strategy of accessing all the types in a 
consistent way if it's built-in or not.

SchemaGrammar grammar = 
grammarResolver.getGrammar(SchemaSymbols.URI_SCHEMAFORSCHEMA);
XSType type = grammar.getTypeDecl(typeName);

        or if we still want to do in that way , we can have a method like 
        this in SchemaNSGrammar.
        
public static XSType getSchemaNSTypeDecl(int typeIndex){

return schemaGrammar.getTypeDecl(typeIndex);
}
but i feel we can continue with our first approach of accessing all the types
in consistent way. What's ur opinion Sandy ?

regards

Neeraj Bajaj
---------------------
Sun Microsystems, inc.
Ph.91-80-2298989 x87425.



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

Reply via email to