You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by br...@homepoint.com on 2000/11/16 17:30:55 UTC
Validation & NullPointer
I found an instance where Xerces will throw a NullPointerException in the
parse() method (when validating). Using this example, it should fail with
a validation error - but instead I get the NPE... if I change minOccurs on
the txEvent element to 0 (as it is in the example) it works fine. Just
didn't figure a NP exception was very good...
Thanks,
- Brent
[temp.xml]
<?xml version="1.0"?>
<hp:txFurnitureXML xmlns:hp="http://www.homepoint.com/XML/txFurnitureXML"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:
schemaLocation="http://www.homepoint.com/XML/txFurnitureXML
http://ssdv01:8001/schemas/temp.xsd">
<txControl>
<timeStamp>2000-08-01T18:39:09-08:00</timeStamp>
<testFlag>true</testFlag>
</txControl>
</hp:txFurnitureXML>
[temp.xsd]
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns
="http://www.homepoint.com/XML/txFurnitureXML" targetNamespace="http:/
/www.homepoint.com/XML/txFurnitureXML" elementFormDefault="unqualified"
version="0.5">
<xsd:element name="txFurnitureXML" type="txFurnitureXMLType"/>
<xsd:simpleType name="connectIDType" base="xsd:string"/>
<xsd:simpleType name="passwordType" base="xsd:string"/>
<xsd:complexType name="txFurnitureXMLType" content="elementOnly">
<xsd:element name="txControl" type="txControlType"
minOccurs="1" maxOccurs="1"/>
<xsd:element name="txEvent" type="txEventType" minOccurs
="1" maxOccurs="unbounded"/>
</xsd:complexType>
<xsd:complexType name="txControlType" content="elementOnly">
<xsd:sequence>
<xsd:element name="timeStamp" type
="xsd:timeInstant" minOccurs="1" maxOccurs="1"/>
<xsd:element name="testFlag" type="xsd:boolean"
minOccurs="0" maxOccurs="1" default="false"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="txEventType" content="elementOnly">
<xsd:choice>
</xsd:choice>
</xsd:complexType>
</xsd:schema>
Re: Validation & NullPointer
Posted by Eric Ye <er...@locus.apache.org>.
Can't reproduce the problem with the latest source in CVS, maybe it's
already fixed.
_____
Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org
----- Original Message -----
From: <br...@homepoint.com>
To: <xe...@xml.apache.org>
Sent: Thursday, November 16, 2000 8:30 AM
Subject: Validation & NullPointer
> I found an instance where Xerces will throw a NullPointerException in the
> parse() method (when validating). Using this example, it should fail with
> a validation error - but instead I get the NPE... if I change minOccurs
on
> the txEvent element to 0 (as it is in the example) it works fine. Just
> didn't figure a NP exception was very good...
>
> Thanks,
>
> - Brent
>
> [temp.xml]
>
> <?xml version="1.0"?>
> <hp:txFurnitureXML xmlns:hp="http://www.homepoint.com/XML/txFurnitureXML"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:
> schemaLocation="http://www.homepoint.com/XML/txFurnitureXML
> http://ssdv01:8001/schemas/temp.xsd">
> <txControl>
> <timeStamp>2000-08-01T18:39:09-08:00</timeStamp>
> <testFlag>true</testFlag>
> </txControl>
> </hp:txFurnitureXML>
>
> [temp.xsd]
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns
> ="http://www.homepoint.com/XML/txFurnitureXML" targetNamespace="http:/
> /www.homepoint.com/XML/txFurnitureXML" elementFormDefault="unqualified"
> version="0.5">
> <xsd:element name="txFurnitureXML" type="txFurnitureXMLType"/>
> <xsd:simpleType name="connectIDType" base="xsd:string"/>
> <xsd:simpleType name="passwordType" base="xsd:string"/>
> <xsd:complexType name="txFurnitureXMLType" content="elementOnly">
> <xsd:element name="txControl" type="txControlType"
> minOccurs="1" maxOccurs="1"/>
> <xsd:element name="txEvent" type="txEventType" minOccurs
> ="1" maxOccurs="unbounded"/>
> </xsd:complexType>
> <xsd:complexType name="txControlType" content="elementOnly">
> <xsd:sequence>
> <xsd:element name="timeStamp" type
> ="xsd:timeInstant" minOccurs="1" maxOccurs="1"/>
> <xsd:element name="testFlag" type="xsd:boolean"
> minOccurs="0" maxOccurs="1" default="false"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="txEventType" content="elementOnly">
> <xsd:choice>
> </xsd:choice>
> </xsd:complexType>
> </xsd:schema>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>
Re: Validation & NullPointer
Posted by Neil Graham <ne...@jtcsv.com>.
Hi Brent,
Interestingly enough, I was not able to reproduce your error--at least
not quite. When I used the proper filename in the schemaLocation
attribute, I got a nice error message both with the SAX and DOM parser.
But, when I used a wrong filename in schemaLocation, I got a
nullPointerException. Can you make sure you're schemaLocation i right?
So the NP is there, but for a different reason... I'll see if I can
track it down.
Cheers,
Neil Graham
brent.johnson@homepoint.com wrote:
>
> I found an instance where Xerces will throw a NullPointerException in the
> parse() method (when validating). Using this example, it should fail with
> a validation error - but instead I get the NPE... if I change minOccurs on
> the txEvent element to 0 (as it is in the example) it works fine. Just
> didn't figure a NP exception was very good...
>
> Thanks,
>
> - Brent
>
> [temp.xml]
>
> <?xml version="1.0"?>
> <hp:txFurnitureXML xmlns:hp="http://www.homepoint.com/XML/txFurnitureXML"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xsi:
> schemaLocation="http://www.homepoint.com/XML/txFurnitureXML
> http://ssdv01:8001/schemas/temp.xsd">
> <txControl>
> <timeStamp>2000-08-01T18:39:09-08:00</timeStamp>
> <testFlag>true</testFlag>
> </txControl>
> </hp:txFurnitureXML>
>
> [temp.xsd]
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns
> ="http://www.homepoint.com/XML/txFurnitureXML" targetNamespace="http:/
> /www.homepoint.com/XML/txFurnitureXML" elementFormDefault="unqualified"
> version="0.5">
> <xsd:element name="txFurnitureXML" type="txFurnitureXMLType"/>
> <xsd:simpleType name="connectIDType" base="xsd:string"/>
> <xsd:simpleType name="passwordType" base="xsd:string"/>
> <xsd:complexType name="txFurnitureXMLType" content="elementOnly">
> <xsd:element name="txControl" type="txControlType"
> minOccurs="1" maxOccurs="1"/>
> <xsd:element name="txEvent" type="txEventType" minOccurs
> ="1" maxOccurs="unbounded"/>
> </xsd:complexType>
> <xsd:complexType name="txControlType" content="elementOnly">
> <xsd:sequence>
> <xsd:element name="timeStamp" type
> ="xsd:timeInstant" minOccurs="1" maxOccurs="1"/>
> <xsd:element name="testFlag" type="xsd:boolean"
> minOccurs="0" maxOccurs="1" default="false"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:complexType name="txEventType" content="elementOnly">
> <xsd:choice>
> </xsd:choice>
> </xsd:complexType>
> </xsd:schema>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org