NPE on getAnnotation() for not present in schema datatype
---------------------------------------------------------

         Key: XERCESJ-1149
         URL: http://issues.apache.org/jira/browse/XERCESJ-1149
     Project: Xerces2-J
        Type: Bug
  Components: XML Schema datatypes  
 Environment: All
    Reporter: Radu Coravu
    Priority: Minor


Run the following code:

   String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
       "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"; 
targetNamespace='ns'>\n" +
       "    <xs:element name=\"personnel\"/>\n" +
       "</xs:schema>";
   XsModelCreator creator = new XsModelCreator();
   SymbolTable symbolTable = new SymbolTable();
   InputSource src = new InputSource(new StringReader(content));
   src.setSystemId("fake");
   // Preparser setup.
   XMLGrammarPreparser preparser = new XMLGrammarPreparser(symbolTable);
   preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);       
// Selects the grammar pool.
   XMLGrammarPool grammarPool= new XMLGrammarPoolImpl();
   preparser.setGrammarPool(grammarPool);
   preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, new 
XMLInputSource(
       src.getPublicId(),
       src.getSystemId(),
       null,
       src.getCharacterStream(),
       src.getEncoding()));
   XSModel xsModel = creator.newXSModel(grammarPool);       
   XSElementDeclaration elemDecl = xsModel.getElementDeclaration("personnel", 
"ns");
   XSComplexTypeDefinition typeDefinition = (XSComplexTypeDefinition) 
elemDecl.getTypeDefinition();
   XSWildcard attributeWildCard = typeDefinition.getAttributeWildcard();
   attributeWildCard.getAnnotation();//This should throw the NPE.

As you can see, the personnel element has no associated data typed but it is 
mapped by default to anyType in the Xerces structure.
This NPE also happens when getAnnotation() is called for nodes of types 
XSElementDeclaration, XSWildcard, XSModelGroup which do not actually appear in 
the schema (they can be obtained by exploring the XSComplexTypeDefinition of 
the anyType).


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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

Reply via email to