You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jeff Greif <jg...@alumni.princeton.edu> on 2002/12/14 18:58:05 UTC

namespace in XSElementDeclaration for locally-declared elements

In Xerces 2.1.0 and 2.2.1, it appears that if I produce a schema model using 
   XMLSchemaLoader loader = new XMLSchemaLoader();
   SchemaGrammar grammar = loader.loadGrammar(...);
   XSModel model = grammar.toXSModel();

and then look at a global type definition, there is a non-null namespace.  If I look at one of the XSElementDeclaration elements declared locally by that type definition, it has a null namespace (as returned by getNamespace()).  This seems less than ideal since if I were using this model to construct or examine instances of the model I would need to have the namespace for these elements handy, and it has to be the target namespace of the model, which is not readily available from the XSElementDeclaration itself.

Is this behavior mandated by the XML Schema spec?  Can the namespace be set in the XSElementDecl by setting some feature on the schema loader or the grammar produced by it?  If neither, is there some easy way to get the namespace other than passing it around in all the traversal code?

Jeff

Re: namespace in XSElementDeclaration for locally-declared elements

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
Oops -- my mistake.  Forgot "elementFormDefault='qualified'" in the schema!  
Jeff
  ----- Original Message ----- 
  From: Jeff Greif 
  To: xerces-j-user@xml.apache.org 
  Sent: Saturday, December 14, 2002 9:58 AM
  Subject: namespace in XSElementDeclaration for locally-declared elements


  In Xerces 2.1.0 and 2.2.1, it appears that if I produce a schema model using 
     XMLSchemaLoader loader = new XMLSchemaLoader();
     SchemaGrammar grammar = loader.loadGrammar(...);
     XSModel model = grammar.toXSModel();

  and then look at a global type definition, there is a non-null namespace.  If I look at one of the XSElementDeclaration elements declared locally by that type definition, it has a null namespace (as returned by getNamespace()).  This seems less than ideal since if I were using this model to construct or examine instances of the model I would need to have the namespace for these elements handy, and it has to be the target namespace of the model, which is not readily available from the XSElementDeclaration itself.

  Is this behavior mandated by the XML Schema spec?  Can the namespace be set in the XSElementDecl by setting some feature on the schema loader or the grammar produced by it?  If neither, is there some easy way to get the namespace other than passing it around in all the traversal code?

  Jeff