You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Dvir Ofek <dv...@ScreenPeaks.com> on 2002/10/01 15:53:23 UTC

Is something wrong with my import?

Hi
I have this problem which might be a dumb thing after all, but I would
really appreciate any help available.
I'm using Xerces 2.1.0 and my instance document is using a schema which
imports it's types from another schema, simple hah?
That's what I thought, but unfortunately I get the following error:

An exception occurred! Type:RuntimeException, Message:Warning: The primary
document entity could not be opened. Id=

As you can see the Id is empty, so I tried to override the EntityResolver
and noticed the systemId is really empty.
This only happens with <import>, since when I embed the types in the first
schema instead of importing them - everything's fine.
Btw: XMLSpy says everything's alright.
I'm attaching a short fragment of the schemas (they are much longer), but it
should produce the same behavior:

The main schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.screenpeaks.com/schema/generic"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:gt="http://www.screenpeaks.com/schema/genericTypes"
xmlns="http://www.screenpeaks.com/schema/generic"
elementFormDefault="qualified">
	<xs:import
namespace="http://www.screenpeaks.com/schema/genericTypes"
schemaLocation="GenericTypes.xsd"/>
	<xs:element name="VICData">
		<xs:complexType>
			<xs:choice maxOccurs="unbounded">
				<xs:element ref="Frames"/>
			</xs:choice>
		</xs:complexType>
	</xs:element>
	<xs:element name="Frames">
		<xs:complexType>
			<xs:sequence>
				<xs:element ref="Frame"
maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Frame">
		<xs:complexType>
			<xs:sequence maxOccurs="unbounded">
				<xs:choice>
					<xs:element ref="Text"/>
				</xs:choice>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Frame">
		<xs:complexType>
			<xs:sequence maxOccurs="unbounded">
				<xs:choice>
					<xs:element ref="Text"/>
				</xs:choice>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<xs:element name="Text">
		<xs:complexType mixed="true">
			<xs:attribute name="Font" type="gt:font"
use="optional" default="Arial"/>
			<xs:attribute name="Left" type="gt:xCoord"
use="required"/>
			<xs:attribute name="Top" type="gt:yCoord"
use="required"/>
			<xs:attribute name="Right" type="gt:xCoord"
use="required"/>
			<xs:attribute name="Bottom" type="gt:yCoord"
use="required"/>
			<xs:attribute name="Size" type="gt:fontSize"
use="optional" default="26"/>
			<xs:attribute name="Color" type="gt:color"
use="optional" default="000000"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

The imported types:
<?xml version="1.0" encoding="UTF-8"?>
<!-- VIC-TV ver 2.0 -->
<!-- All rights reserved to Screenpeaks Ltd. 2002 -->
<xs:schema targetNamespace="http://www.screenpeaks.com/schema/genericTypes"
xmlns="http://www.screenpeaks.com/schema/genericTypes"
xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified"
attributeFormDefault="unqualified">
	<!-- Types -->
	<xs:simpleType name="font">
		<xs:restriction base="xs:string">
			<xs:minLength value="1"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="fontSize">
		<xs:restriction base="xs:unsignedInt">
			<xs:minInclusive value="26"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="yCoord">
		<xs:restriction base="xs:unsignedInt">
			<xs:minInclusive value="0"/>
			<xs:maxInclusive value="575"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="xCoord">
		<xs:restriction base="xs:unsignedInt">
			<xs:minInclusive value="0"/>
			<xs:maxInclusive value="719"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="color">
		<xs:restriction base="xs:string">
			<xs:pattern value="([A-F]|[a-f]|\d){6}"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

The xml document:
<?xml version="1.0" encoding="UTF-8"?>
<VICData xmlns="http://www.screenpeaks.com/schema/generic">
	<Frames>
		<Frame>
			<Text Left="100" Top="100" Right="500"
Bottom="500">mumu</Text>
		</Frame>
	</Frames>
</VICData>

(The schema location for the namespaces is set inside the code).
What's going on here?

Cheers
Dvir Ofek
Software Engineer
Screenpeaks Ltd.



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Is something wrong with my import?

Posted by "Peter A. Volchek" <Pe...@ti.com.od.ua>.
Dvir,

I have reviewed your schemas and run some of my tools to check their
validaty.

- First:
Your main schema contains duplicated declaration of the "Frame" element.

- Second:
Propose to change the declaration of the "Text" element as:

  <xs:element name="Text">
    <xs:complexType>
      <xs:simpleContent>
          <xs:extension base="xs:string">
             <xs:attribute name="Font"   type="gt:font"     use="optional"
default="Arial"/>
             <xs:attribute name="Left"   type="gt:xCoord"   use="required"/>
             <xs:attribute name="Top"    type="gt:yCoord"   use="required"/>
             <xs:attribute name="Right"  type="gt:xCoord"   use="required"/>
             <xs:attribute name="Bottom" type="gt:yCoord"   use="required"/>
             <xs:attribute name="Size"   type="gt:fontSize" use="optional"
default="26"/>
             <xs:attribute name="Color"  type="gt:color"    use="optional"
default="000000"/>
          </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

- Third

> (The schema location for the namespaces is set inside the code).
Hope you did it right.

To test your schemas, I have created the instance document with schema
declaration:

<?xml version="1.0" ?>
<VICData xmlns="http://www.screenpeaks.com/schema/generic"
               xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
               xsi:schemaLocation="http://www.screenpeaks.com/schema/generic
generic.xsd">

Check that in your code you called
yourParser.setExternalSchemaLocation( url ) method, where url is:
url = "http://www.screenpeaks.com/schema/generic" + chSpace + "generic.xsd"


After all changes, my validation tools have successfully parsed and
validated your schema

- Fourth
I was not able to validate your schema with DOMPrint tool
So this is a note for development team, please verify what is wrong
The test files attached


Regards, Peter






----- Original Message -----
From: "Dvir Ofek" <dv...@ScreenPeaks.com>
To: "Xerces-C-dev@Xml. Apache. Org (E-mail)" <Xe...@xml.apache.org>
Sent: Tuesday, October 01, 2002 4:53 PM
Subject: Is something wrong with my import?


> Hi
> I have this problem which might be a dumb thing after all, but I would
> really appreciate any help available.
> I'm using Xerces 2.1.0 and my instance document is using a schema which
> imports it's types from another schema, simple hah?
> That's what I thought, but unfortunately I get the following error:
>
> An exception occurred! Type:RuntimeException, Message:Warning: The primary
> document entity could not be opened. Id=
>
> As you can see the Id is empty, so I tried to override the EntityResolver
> and noticed the systemId is really empty.
> This only happens with <import>, since when I embed the types in the first
> schema instead of importing them - everything's fine.
> Btw: XMLSpy says everything's alright.
> I'm attaching a short fragment of the schemas (they are much longer), but
it
> should produce the same behavior:
>
> The main schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.screenpeaks.com/schema/generic"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:gt="http://www.screenpeaks.com/schema/genericTypes"
> xmlns="http://www.screenpeaks.com/schema/generic"
> elementFormDefault="qualified">
> <xs:import
> namespace="http://www.screenpeaks.com/schema/genericTypes"
> schemaLocation="GenericTypes.xsd"/>
> <xs:element name="VICData">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element ref="Frames"/>
> </xs:choice>
> </xs:complexType>
> </xs:element>
> <xs:element name="Frames">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="Frame"
> maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="Frame">
> <xs:complexType>
> <xs:sequence maxOccurs="unbounded">
> <xs:choice>
> <xs:element ref="Text"/>
> </xs:choice>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="Frame">
> <xs:complexType>
> <xs:sequence maxOccurs="unbounded">
> <xs:choice>
> <xs:element ref="Text"/>
> </xs:choice>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="Text">
> <xs:complexType mixed="true">
> <xs:attribute name="Font" type="gt:font"
> use="optional" default="Arial"/>
> <xs:attribute name="Left" type="gt:xCoord"
> use="required"/>
> <xs:attribute name="Top" type="gt:yCoord"
> use="required"/>
> <xs:attribute name="Right" type="gt:xCoord"
> use="required"/>
> <xs:attribute name="Bottom" type="gt:yCoord"
> use="required"/>
> <xs:attribute name="Size" type="gt:fontSize"
> use="optional" default="26"/>
> <xs:attribute name="Color" type="gt:color"
> use="optional" default="000000"/>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> The imported types:
> <?xml version="1.0" encoding="UTF-8"?>
> <!-- VIC-TV ver 2.0 -->
> <!-- All rights reserved to Screenpeaks Ltd. 2002 -->
> <xs:schema
targetNamespace="http://www.screenpeaks.com/schema/genericTypes"
> xmlns="http://www.screenpeaks.com/schema/genericTypes"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified"
> attributeFormDefault="unqualified">
> <!-- Types -->
> <xs:simpleType name="font">
> <xs:restriction base="xs:string">
> <xs:minLength value="1"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="fontSize">
> <xs:restriction base="xs:unsignedInt">
> <xs:minInclusive value="26"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="yCoord">
> <xs:restriction base="xs:unsignedInt">
> <xs:minInclusive value="0"/>
> <xs:maxInclusive value="575"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="xCoord">
> <xs:restriction base="xs:unsignedInt">
> <xs:minInclusive value="0"/>
> <xs:maxInclusive value="719"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:simpleType name="color">
> <xs:restriction base="xs:string">
> <xs:pattern value="([A-F]|[a-f]|\d){6}"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:schema>
>
> The xml document:
> <?xml version="1.0" encoding="UTF-8"?>
> <VICData xmlns="http://www.screenpeaks.com/schema/generic">
> <Frames>
> <Frame>
> <Text Left="100" Top="100" Right="500"
> Bottom="500">mumu</Text>
> </Frame>
> </Frames>
> </VICData>
>
> (The schema location for the namespaces is set inside the code).
> What's going on here?
>
> Cheers
> Dvir Ofek
> Software Engineer
> Screenpeaks Ltd.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>