Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
unspecified
-
None
-
None
-
Operating System: Windows NT/2K
Platform: PC
-
26105
Description
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>