[ http://issues.apache.org/jira/browse/XERCESJ-1149?page=all ] Michael Glavassevich resolved XERCESJ-1149: -------------------------------------------
Resolution: Fixed The enhancements made to the annotation support in Xerces 2.8.0 made it possible for NPEs to be thrown from the various XSObjects when a component has no annotations. In all getAnnotation() methods we now check if the list is null before accessing it. That should fix all of the NPEs. > 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 > Versions: 2.8.0 > Environment: All > Reporter: Radu Coravu > Assignee: Michael Glavassevich > 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]