Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-66

NullPointerException when restricting a union with one of the union members

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Version 2
    • Version 2 Beta 1
    • Compiler
    • None

    Description

      Compile the following trimmed down schema from http://w3.org/TR/xqueryx/#Schema:

      <?xml version="1.0" encoding="UTF-8"?>
      <xsd:schema targetNamespace="http://www.w3.org/2003/12/XQueryX"
      xmlns="http://www.w3.org/2003/12/XQueryX"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified"
      attributeFormDefault="qualified">

      <!-- Kludge for anySimpleType -->
      <xsd:simpleType name="constantValueType">
      <xsd:union memberTypes="xsd:integer xsd:decimal xsd:string xsd:double"/>
      </xsd:simpleType>

      <!-- constant expressions. We have 4 different subclasses for this -->
      <xsd:complexType name="constantExpr">
      <xsd:sequence>
      <xsd:element name="value" type="constantValueType"/>
      </xsd:sequence>
      </xsd:complexType>

      <xsd:complexType name="integerConstantExpr">
      <xsd:complexContent>
      <xsd:restriction base="constantExpr">
      <xsd:sequence>
      <xsd:element name="value" type="xsd:integer"/>
      </xsd:sequence>
      </xsd:restriction>
      </xsd:complexContent>
      </xsd:complexType>

      </xsd:schema>

      results in:

      Exception in thread "main" java.lang.NullPointerException
      at org.apache.xmlbeans.impl.schema.StscChecker.checkAllDerivationsForRestriction(StscChecker.java:1412)
      at org.apache.xmlbeans.impl.schema.StscChecker.typeDerivationOK(StscChecker.java:1394)
      at org.apache.xmlbeans.impl.schema.StscChecker.nameAndTypeOK(StscChecker.java:1337)
      at org.apache.xmlbeans.impl.schema.StscChecker.isParticleValidRestriction(StscChecker.java:404)
      at org.apache.xmlbeans.impl.schema.StscChecker.checkRestriction(StscChecker.java:364)
      at org.apache.xmlbeans.impl.schema.StscChecker.checkAll(StscChecker.java:63)
      at org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compileImpl(SchemaTypeSystemCompiler.java:268)
      at org.apache.xmlbeans.impl.schema.SchemaTypeSystemCompiler.compile(SchemaTypeSystemCompiler.java:195)
      at org.apache.xmlbeans.impl.tool.SchemaCompiler.loadTypeSystem(SchemaCompiler.java:853)
      at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:911)
      at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:330)

      When checkAllDerivationsForRestriction() loops from the derived type down to the base, if the type is a union we continue following one of the types (that is assignable). What is happening now is the derived type is never reaching the base type since the base type is one of the union members.

      Attachments

        Activity

          People

            jacobd Jacob Danner
            kkrouse@bea.com Kevin Krouse
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: