Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » NPE during schema validation
NPE during schema validation [message #45440] Tue, 25 May 2004 14:41 Go to next message
test is currently offline testFriend
Messages: 51
Registered: July 2009
Member
I'm putting together some testcases for an XSD based project I'm working
on when I hit a NullPointerException validating a somewhat contrived
schema. I'm not even certain that the schema is valid, but if it isn't I
would have thought that there would be a more meaningful diagnostic than
an NPE so I figured I'd raise it with you guys to see what you think.

Here's my schema:

<schema targetNamespace="http://com/schemas/ACTDIInterface"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd1="http://com/schemas/ACTDIInterface">
<complexType name="CAType">
<sequence>
<element name="el1" type="xsd1:typeRef"/>
</sequence>
</complexType>
<simpleType name="typeRef">
<restriction base="string"/>
</simpleType>
<element name="CA" substitutionGroup="xsd1:CA2" abstract="false"
final="#all"/>
<element name="CA2" ref="xsd1:CA3" abstract="false" />
<element name="CA3" type="xsd1:CAType" abstract="false" />
</schema>

The problem seems to be related to element CA which has a
substitutionGroup of CA2 which in turn references CA3. This may be an
illegal scenario for all I know.

Here is the exception stack trace:

java.lang.NullPointerException
at
org.eclipse.xsd.impl.XSDElementDeclarationImpl.validate(XSDE lementDeclarationImpl.java:1016)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.validate(XSDCo ncreteComponentImpl.java:541)
at org.eclipse.xsd.impl.XSDSchemaImpl.validate(XSDSchemaImpl.ja va:1493)
at ...



Paul.
Re: NPE during schema validation [message #45501 is a reply to message #45440] Tue, 25 May 2004 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

you have not declared a type in <element name="CA"
substitutionGroup="xsd1:CA2" abstract="false"
final="#all"/> so anyType is assumed. however, the type must be
the type or a subtype of the head of the substitution group and that
type is type="xsd1:CAType" by reference to CA3. anyType is a supertype,
not a subtype, of xsd1:CAType so the schema is not valid.

norwood sisson

me@me.com wrote:
> I'm putting together some testcases for an XSD based project I'm working
> on when I hit a NullPointerException validating a somewhat contrived
> schema. I'm not even certain that the schema is valid, but if it isn't I
> would have thought that there would be a more meaningful diagnostic than
> an NPE so I figured I'd raise it with you guys to see what you think.
>
> Here's my schema:
>
> <schema targetNamespace="http://com/schemas/ACTDIInterface"
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:xsd1="http://com/schemas/ACTDIInterface">
> <complexType name="CAType">
> <sequence>
> <element name="el1" type="xsd1:typeRef"/>
> </sequence>
> </complexType>
> <simpleType name="typeRef">
> <restriction base="string"/>
> </simpleType>
> <element name="CA" substitutionGroup="xsd1:CA2" abstract="false"
> final="#all"/>
> <element name="CA2" ref="xsd1:CA3" abstract="false" />
> <element name="CA3" type="xsd1:CAType" abstract="false" />
> </schema>
>
> The problem seems to be related to element CA which has a
> substitutionGroup of CA2 which in turn references CA3. This may be an
> illegal scenario for all I know.
>
> Here is the exception stack trace:
>
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDElementDeclarationImpl.validate(XSDE lementDeclarationImpl.java:1016)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.validate(XSDCo ncreteComponentImpl.java:541)
>
> at org.eclipse.xsd.impl.XSDSchemaImpl.validate(XSDSchemaImpl.ja va:1493)
> at ...
>
>
>
> Paul.
Re: NPE during schema validation [message #45530 is a reply to message #45501] Tue, 25 May 2004 15:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: NOpcooperSPAM.uk.ibm.com

Ok, that sounds convincing. Thanks for the fast response.

I do think if it would be better for this error scenario to be reported
either as a diagnostic or as a more meaningful exception rather than as
a NullPointerException. I've managed to code a whole load of erroneous
schemas so far but this is the first time I've had an NPE out of the XSD
validation code.

If the schema is at fault then, as a general rule, I like to be able to
return some kind of vaguely meaningful message to the user. In this
scenario all I can really do is report that schema validation failed.

Thanks.

Paul.
Re: NPE during schema validation [message #45560 is a reply to message #45530] Tue, 25 May 2004 16:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Paul,

It should't produce an NPE. Please open a bugzilla for your sample schema.


Paul Cooper wrote:

> Ok, that sounds convincing. Thanks for the fast response.
>
> I do think if it would be better for this error scenario to be reported
> either as a diagnostic or as a more meaningful exception rather than as
> a NullPointerException. I've managed to code a whole load of erroneous
> schemas so far but this is the first time I've had an NPE out of the XSD
> validation code.
>
> If the schema is at fault then, as a general rule, I like to be able to
> return some kind of vaguely meaningful message to the user. In this
> scenario all I can really do is report that schema validation failed.
>
> Thanks.
>
> Paul.
Re: NPE during schema validation [message #45648 is a reply to message #45560] Tue, 25 May 2004 17:04 Go to previous message
Eclipse UserFriend
Originally posted by: NOpcooperSPAM.uk.ibm.com

I've opened Bug Report 63916.

Thanks.


Ed Merks wrote:

> Paul,
>
> It should't produce an NPE. Please open a bugzilla for your sample schema.
>
>
> Paul Cooper wrote:
>
>
>>Ok, that sounds convincing. Thanks for the fast response.
>>
>>I do think if it would be better for this error scenario to be reported
>>either as a diagnostic or as a more meaningful exception rather than as
>>a NullPointerException. I've managed to code a whole load of erroneous
>>schemas so far but this is the first time I've had an NPE out of the XSD
>>validation code.
>>
>>If the schema is at fault then, as a general rule, I like to be able to
>>return some kind of vaguely meaningful message to the user. In this
>>scenario all I can really do is report that schema validation failed.
>>
>>Thanks.
>>
>>Paul.
>
>
Re: NPE during schema validation [message #587514 is a reply to message #45440] Tue, 25 May 2004 15:27 Go to previous message
user is currently offline userFriend
Messages: 296
Registered: July 2009
Senior Member
you have not declared a type in <element name="CA"
substitutionGroup="xsd1:CA2" abstract="false"
final="#all"/> so anyType is assumed. however, the type must be
the type or a subtype of the head of the substitution group and that
type is type="xsd1:CAType" by reference to CA3. anyType is a supertype,
not a subtype, of xsd1:CAType so the schema is not valid.

norwood sisson

me@me.com wrote:
> I'm putting together some testcases for an XSD based project I'm working
> on when I hit a NullPointerException validating a somewhat contrived
> schema. I'm not even certain that the schema is valid, but if it isn't I
> would have thought that there would be a more meaningful diagnostic than
> an NPE so I figured I'd raise it with you guys to see what you think.
>
> Here's my schema:
>
> <schema targetNamespace="http://com/schemas/ACTDIInterface"
> xmlns="http://www.w3.org/2001/XMLSchema"
> xmlns:xsd1="http://com/schemas/ACTDIInterface">
> <complexType name="CAType">
> <sequence>
> <element name="el1" type="xsd1:typeRef"/>
> </sequence>
> </complexType>
> <simpleType name="typeRef">
> <restriction base="string"/>
> </simpleType>
> <element name="CA" substitutionGroup="xsd1:CA2" abstract="false"
> final="#all"/>
> <element name="CA2" ref="xsd1:CA3" abstract="false" />
> <element name="CA3" type="xsd1:CAType" abstract="false" />
> </schema>
>
> The problem seems to be related to element CA which has a
> substitutionGroup of CA2 which in turn references CA3. This may be an
> illegal scenario for all I know.
>
> Here is the exception stack trace:
>
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDElementDeclarationImpl.validate(XSDE lementDeclarationImpl.java:1016)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.validate(XSDCo ncreteComponentImpl.java:541)
>
> at org.eclipse.xsd.impl.XSDSchemaImpl.validate(XSDSchemaImpl.ja va:1493)
> at ...
>
>
>
> Paul.
Re: NPE during schema validation [message #587534 is a reply to message #45501] Tue, 25 May 2004 15:41 Go to previous message
Paul Cooper is currently offline Paul CooperFriend
Messages: 11
Registered: July 2009
Junior Member
Ok, that sounds convincing. Thanks for the fast response.

I do think if it would be better for this error scenario to be reported
either as a diagnostic or as a more meaningful exception rather than as
a NullPointerException. I've managed to code a whole load of erroneous
schemas so far but this is the first time I've had an NPE out of the XSD
validation code.

If the schema is at fault then, as a general rule, I like to be able to
return some kind of vaguely meaningful message to the user. In this
scenario all I can really do is report that schema validation failed.

Thanks.

Paul.
Re: NPE during schema validation [message #587547 is a reply to message #45530] Tue, 25 May 2004 16:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Paul,

It should't produce an NPE. Please open a bugzilla for your sample schema.


Paul Cooper wrote:

> Ok, that sounds convincing. Thanks for the fast response.
>
> I do think if it would be better for this error scenario to be reported
> either as a diagnostic or as a more meaningful exception rather than as
> a NullPointerException. I've managed to code a whole load of erroneous
> schemas so far but this is the first time I've had an NPE out of the XSD
> validation code.
>
> If the schema is at fault then, as a general rule, I like to be able to
> return some kind of vaguely meaningful message to the user. In this
> scenario all I can really do is report that schema validation failed.
>
> Thanks.
>
> Paul.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: NPE during schema validation [message #587583 is a reply to message #45560] Tue, 25 May 2004 17:04 Go to previous message
Paul Cooper is currently offline Paul CooperFriend
Messages: 11
Registered: July 2009
Junior Member
I've opened Bug Report 63916.

Thanks.


Ed Merks wrote:

> Paul,
>
> It should't produce an NPE. Please open a bugzilla for your sample schema.
>
>
> Paul Cooper wrote:
>
>
>>Ok, that sounds convincing. Thanks for the fast response.
>>
>>I do think if it would be better for this error scenario to be reported
>>either as a diagnostic or as a more meaningful exception rather than as
>>a NullPointerException. I've managed to code a whole load of erroneous
>>schemas so far but this is the first time I've had an NPE out of the XSD
>>validation code.
>>
>>If the schema is at fault then, as a general rule, I like to be able to
>>return some kind of vaguely meaningful message to the user. In this
>>scenario all I can really do is report that schema validation failed.
>>
>>Thanks.
>>
>>Paul.
>
>
Previous Topic:NPE during schema validation
Next Topic:binding during multiple loads
Goto Forum:
  


Current Time: Wed Apr 24 21:21:37 GMT 2024

Powered by FUDForum. Page generated in 0.03472 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top