You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-dev@xml.apache.org by bu...@apache.org on 2004/01/13 20:03:35 UTC

DO NOT REPLY [Bug 26105] New: - Null Pointer Exception on enumeration

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26105>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26105

Null Pointer Exception on enumeration

           Summary: Null Pointer Exception on enumeration
           Product: XMLBeans
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: Validator
        AssignedTo: xmlbeans-dev@xml.apache.org
        ReportedBy: toby.h.ferguson@sun.com


Using the validator in v1 I get a null pointer exception when I attempt to
validate an XML instance document against a schema.

I list the terminal session and the contents of the schema (schema.xsd) and the
instance document (valid.xml) in that order below. Each section starts with +++

+++ terminal session
bash$ validate schema.xsd valid.xml
java.lang.NullPointerException
	at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.ensureStringEnumInfo(SchemaTypeImpl.java:1354)
	at
org.apache.xmlbeans.impl.schema.SchemaTypeImpl.enumForString(SchemaTypeImpl.java:1289)
	at
org.apache.xmlbeans.impl.values.JavaStringEnumerationHolderEx.validateLexical(JavaStringEnumerationHolderEx.java:91)
	at
org.apache.xmlbeans.impl.validator.Validator.validateAtomicType(Validator.java:1050)
	at
org.apache.xmlbeans.impl.validator.Validator.validateSimpleType(Validator.java:1020)
	at
org.apache.xmlbeans.impl.validator.Validator.validateSimpleType(Validator.java:975)
	at org.apache.xmlbeans.impl.validator.Validator.handleText(Validator.java:744)
	at org.apache.xmlbeans.impl.validator.Validator.textEvent(Validator.java:729)
	at org.apache.xmlbeans.impl.validator.Validator.nextEvent(Validator.java:226)
	at org.apache.xmlbeans.impl.store.Saver$ValidatorSaver.emitEvent(Saver.java:3803)
	at org.apache.xmlbeans.impl.store.Saver$ValidatorSaver.emitEvent(Saver.java:3774)
	at
org.apache.xmlbeans.impl.store.Saver$ValidatorSaver.emitContainer(Saver.java:3753)
	at org.apache.xmlbeans.impl.store.Saver.processContainer(Saver.java:818)
	at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:561)
	at org.apache.xmlbeans.impl.store.Saver$ValidatorSaver.<init>(Saver.java:3592)
	at org.apache.xmlbeans.impl.store.Type.validate(Type.java:321)
	at org.apache.xmlbeans.impl.values.XmlObjectBase.validate(XmlObjectBase.java:351)
	at org.apache.xmlbeans.impl.tool.InstanceValidator.main(InstanceValidator.java:171)
Exception in thread "main" bash$

+++ Contents of schema.xsd
<?xml version = "1.0" encoding = "UTF-8"?>
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema">
  <xsd:element name="doc">
    <xsd:complexType>
      <xsd:sequence>
	<xsd:element ref="defns" minOccurs="1" maxOccurs="1"/>
	<xsd:element ref="refs" minOccurs="1" maxOccurs="1"/>
      </xsd:sequence>
    </xsd:complexType>
    <xsd:key name="enumKeys">
      <xsd:selector xpath=".//defns/enumDef"/>
      <xsd:field xpath="@key"/>
    </xsd:key>
    <xsd:keyref name="enumKeyRef" refer="enumKeys">
      <xsd:selector xpath="./refs/enumRef"/>
      <xsd:field xpath="."/>
    </xsd:keyref>
  </xsd:element>

  <xsd:element name="defns" type="defnsType"/>
  <xsd:element name="enumDef" type="enumDefType"/>
  <xsd:element name="refs" type="refsType"/>
  <xsd:element name="enumRef" type="enumRefType"/>
  
  <xsd:complexType name="defnsType">
    <xsd:sequence>
      <xsd:element ref="enumDef"/>
    </xsd:sequence>
  </xsd:complexType>
  
  
  <xsd:complexType name="enumDefType">
    <xsd:simpleContent>
      <xsd:extension base="enumType">
	<xsd:attribute name="key" type="xsd:string"/>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  
  <xsd:simpleType name="enumRefType">
    <xsd:restriction base="enumType"/>
  </xsd:simpleType>
  
  <xsd:simpleType name="enumType">
    <xsd:restriction base="xsd:token">
      <xsd:enumeration value="enum1"/>
      <xsd:enumeration value="enum2"/>
    </xsd:restriction>
  </xsd:simpleType>
  
  <xsd:complexType name="refsType">
    <xsd:sequence>
      <xsd:element ref="enumRef"/>
    </xsd:sequence>
  </xsd:complexType>
  
</xsd:schema>

+++ contents of valid.xml
<?xml version="1.0"?>
<doc>
  <defns>
    <enumDef key="one">enum1</enumDef>
  </defns>
  <refs>
    <enumRef>one</enumRef>
  </refs>
</doc>

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-dev-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/