Author: mukulg Date: Fri Jan 13 08:34:59 2012 New Revision: 1230915 URL: http://svn.apache.org/viewvc?rev=1230915&view=rev Log: fixing a potential NPE issue.
Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java?rev=1230915&r1=1230914&r2=1230915&view=diff ============================================================================== --- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java (original) +++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/traversers/XSDComplexTypeTraverser.java Fri Jan 13 08:34:59 2012 @@ -1696,35 +1696,33 @@ class XSDComplexTypeTraverser extends X // get 'annotation' Element childNode = DOMUtil.getFirstChildElement(assertElement); XSAnnotationImpl annotation = null; - // first child could be an annotation - if (childNode != null - && DOMUtil.getLocalName(childNode).equals( - SchemaSymbols.ELT_ANNOTATION)) { - annotation = traverseAnnotationDecl(childNode, attrValues, false, schemaDoc); - // now move on to the next child element - childNode = DOMUtil.getNextSiblingElement(childNode); - - if (childNode != null) { - // it's an error to have something after the annotation, in 'assert' - reportSchemaError("s4s-elt-invalid-content.1", new Object[] { - DOMUtil.getLocalName(assertElement), - DOMUtil.getLocalName(childNode) }, childNode); - } - } else { - String text = DOMUtil.getSyntheticAnnotation(childNode); - if (text != null) { - annotation = traverseSyntheticAnnotation(childNode, text, attrValues, false, schemaDoc); + if (childNode != null) { + if (DOMUtil.getLocalName(childNode).equals(SchemaSymbols.ELT_ANNOTATION)) { + annotation = traverseAnnotationDecl(childNode, attrValues, false, schemaDoc); + // now move on to the next child element + childNode = DOMUtil.getNextSiblingElement(childNode); + + if (childNode != null) { + // it's an error to have something after the annotation, in 'assert' + reportSchemaError("s4s-elt-invalid-content.1", new Object[] { + DOMUtil.getLocalName(assertElement), + DOMUtil.getLocalName(childNode) }, childNode); + } + } else { + String text = DOMUtil.getSyntheticAnnotation(childNode); + if (text != null) { + annotation = traverseSyntheticAnnotation(childNode, text, attrValues, false, schemaDoc); + } } } - + XSObjectList annotations = null; if (annotation != null) { annotations = new XSObjectListImpl(); ((XSObjectListImpl) annotations).addXSObject(annotation); } else { - // if no annotations are present assign an empty list, for - // annotations. + // if no annotations are present assign an empty list, for annotations. annotations = XSObjectListImpl.EMPTY_LIST; } @@ -1747,15 +1745,12 @@ class XSDComplexTypeTraverser extends X // if there is sibling element if (sibling != null) { if (sibling.getLocalName().equals(SchemaSymbols.ELT_ASSERT)) { - // traverse sibling assertion elements recursively, till - // none is found + // traverse sibling assertion elements recursively, till none is found traverseAsserts(sibling, schemaDoc, grammar, enclosingCT); } else { // a non-assert element after assert is an error fAttrChecker.returnAttrArray(attrValues, schemaDoc); - throw new ComplexTypeRecoverableError( - "s4s-elt-invalid-content.1", new Object[] { fName, - DOMUtil.getLocalName(sibling) }, sibling); + throw new ComplexTypeRecoverableError("s4s-elt-invalid-content.1", new Object[] { fName, DOMUtil.getLocalName(sibling) }, sibling); } } } else { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@xerces.apache.org For additional commands, e-mail: commits-h...@xerces.apache.org