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 Lindsey McNerney <li...@yahoo.com> on 2000/10/03 19:07:22 UTC

error using Import statement

I'm attempting to use the Xerces 1.2 parser to
validate a simple XML instance document with a schema
that uses the import statement to include declarations
from a schema of a different namespace. I get an error
from the parser stating
"java.lang.NullPointerException" followed by a series
of statements the first one being "at
org.apache.xerces.validators.common.Grammar.getFirstAttributeDeclIndex".
 Do I have my namespacing set up incorrectly or am I
not using the prefix aliases correctly?  The samples
are below.  Thank you.

XML file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<TestDocument xmlns = "urn:Test" 
	xmlns:st = "urn:SimpleTypes" 
	xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"

        xsi:schemaLocation= "urn:Test 
        		     Test.xsd" 
        		     urn:SimpleTypes 
        		     SimpleTypes.xsd" 
	Version="1.0" ReferenceNumber="2000-01-01
09:00:32.000" CreationDate="20000315090030"> 
		<LastName>Smith</LastName>
</TestDocument>

Schema with Import:

<?xml version="1.0" encoding="ISO-8859-1"?>
<schema xmlns = "http://www.w3.org/1999/XMLSchema" 
  targetNamespace = "urn:Test" 
  
  xmlns:st = "urn:SimpleTypes" 
  xmlns:test = "urn:Test" 
  elementFormDefault="qualified"
  
 
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xsi:schemaLocation=
"http://www.w3.org/1999/XMLSchema 
http://www.w3.org/1999/XMLSchema.xsd">

<import namespace = "urn:SimpleTypes"
schemaLocation="SimpleTypes.xsd"/>
	
 <element name = "TestDocument">
    <complexType>
        <element name = "LastName" type =
"st:lengthThirtyType"/>
	<attribute name = "Version" type = "st:versionType"
use="required"/>
	<attribute name = "ReferenceNumber" type =
"st:lengthThirtyType" use="required"/>
	<attribute name = "CreationDate" type =
"st:dateTimeType" use="required"/>
     </complexType>
   </element>
</schema>

Schema being imported:

<?xml version="1.0" encoding="ISO-8859-1"?>
<schema xmlns = "http://www.w3.org/1999/XMLSchema" 
  targetNamespace = "urn:SimpleTypes" 
  xmlns:st = "urn:SimpleTypes" 
  elementFormDefault="qualified"
 
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xsi:schemaLocation= "http://www.w3.org/1999/XMLSchema 
http://www.w3.org/1999/XMLSchema.xsd">
		
<simpleType name = "dateTimeType" base = "string">
		<minLength value = "14"/>
		<maxLength value = "14"/>
</simpleType>
	
<simpleType name = "lengthThirtyType" base = "string">
		<minLength value = "1"/>
		<maxLength value = "30"/>
</simpleType>
	
	
<simpleType name = "versionType" base = "string">
		<enumeration value = "1.0"/>
</simpleType>

</schema>

__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/

Re: error using Import statement

Posted by Eric Ye <er...@locus.apache.org>.
I am 90% sure that this is due to a bug in Xerces 1.2.0,  which has been
fixed in the current CVS repository. You can check out the latest source and
give it a try.
_____


Eric Ye * IBM, JTC - Silicon Valley * ericye@locus.apache.org

----- Original Message -----
From: "Lindsey McNerney" <li...@yahoo.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, October 03, 2000 10:07 AM
Subject: error using Import statement


> I'm attempting to use the Xerces 1.2 parser to
> validate a simple XML instance document with a schema
> that uses the import statement to include declarations
> from a schema of a different namespace. I get an error
> from the parser stating
> "java.lang.NullPointerException" followed by a series
> of statements the first one being "at
> org.apache.xerces.validators.common.Grammar.getFirstAttributeDeclIndex".
>  Do I have my namespacing set up incorrectly or am I
> not using the prefix aliases correctly?  The samples
> are below.  Thank you.
>
> XML file:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <TestDocument xmlns = "urn:Test"
> xmlns:st = "urn:SimpleTypes"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
>
>         xsi:schemaLocation= "urn:Test
>              Test.xsd"
>              urn:SimpleTypes
>              SimpleTypes.xsd"
> Version="1.0" ReferenceNumber="2000-01-01
> 09:00:32.000" CreationDate="20000315090030">
> <LastName>Smith</LastName>
> </TestDocument>
>
> Schema with Import:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <schema xmlns = "http://www.w3.org/1999/XMLSchema"
>   targetNamespace = "urn:Test"
>
>   xmlns:st = "urn:SimpleTypes"
>   xmlns:test = "urn:Test"
>   elementFormDefault="qualified"
>
>
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
>   xsi:schemaLocation=
> "http://www.w3.org/1999/XMLSchema
> http://www.w3.org/1999/XMLSchema.xsd">
>
> <import namespace = "urn:SimpleTypes"
> schemaLocation="SimpleTypes.xsd"/>
>
>  <element name = "TestDocument">
>     <complexType>
>         <element name = "LastName" type =
> "st:lengthThirtyType"/>
> <attribute name = "Version" type = "st:versionType"
> use="required"/>
> <attribute name = "ReferenceNumber" type =
> "st:lengthThirtyType" use="required"/>
> <attribute name = "CreationDate" type =
> "st:dateTimeType" use="required"/>
>      </complexType>
>    </element>
> </schema>
>
> Schema being imported:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <schema xmlns = "http://www.w3.org/1999/XMLSchema"
>   targetNamespace = "urn:SimpleTypes"
>   xmlns:st = "urn:SimpleTypes"
>   elementFormDefault="qualified"
>
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:schemaLocation= "http://www.w3.org/1999/XMLSchema
> http://www.w3.org/1999/XMLSchema.xsd">
>
> <simpleType name = "dateTimeType" base = "string">
> <minLength value = "14"/>
> <maxLength value = "14"/>
> </simpleType>
>
> <simpleType name = "lengthThirtyType" base = "string">
> <minLength value = "1"/>
> <maxLength value = "30"/>
> </simpleType>
>
>
> <simpleType name = "versionType" base = "string">
> <enumeration value = "1.0"/>
> </simpleType>
>
> </schema>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
> http://photos.yahoo.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>