You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Michael Glavassevich (JIRA)" <xe...@xml.apache.org> on 2006/03/22 17:13:29 UTC

[jira] Resolved: (XERCESJ-1150) NPE on getAnnotation() for not present in schema datatype

     [ http://issues.apache.org/jira/browse/XERCESJ-1150?page=all ]
     
Michael Glavassevich resolved XERCESJ-1150:
-------------------------------------------

    Resolution: Duplicate

Duplicate of XERCESJ-1149.

> NPE on getAnnotation() for not present in schema datatype
> ---------------------------------------------------------
>
>          Key: XERCESJ-1150
>          URL: http://issues.apache.org/jira/browse/XERCESJ-1150
>      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: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org