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 Eduardo Martinez Gracia <ed...@um.es> on 2001/01/18 12:15:55 UTC

Local and global schema declarations

Does xerces 1.2.3 support local element declarations in shemas?

I have the following schema, with a 'from' element declared globally,
that works fine:

----------sipc.xsd
<?xml version="1.0"?>
<schema targetNamespace="http://aries.dif.um.es/sipc"
		xmlns="http://www.w3.org/1999/XMLSchema"
		xmlns:sipc="http://aries.dif.um.es/sipc">

<element name="profileRequest">
	<complexType>
		<element ref="sipc:from" />
	</complexType>
</element>

<element name="from">
	<complexType content="empty">
		<attribute name="url" 
			type="uriReference" default="http://"/>
	</complexType>
</element>

</schema>
----------

If I use this other schema, with a local declaration of the 'from' 
element, the parsing fails:

----------
<?xml version="1.0"?>
<schema targetNamespace="http://aries.dif.um.es/sipc"
		xmlns="http://www.w3.org/1999/XMLSchema"
		xmlns:sipc="http://aries.dif.um.es/sipc">

<element name="profileRequest">
	<complexType>
		<element name="from">
			<complexType content="empty">
			  <attribute name="url" 
			    type="uriReference" default="http://"/>
			</complexType>
		</element>
	</complexType>
</element>

</schema>
---------

This is the error message given by dom.DOMCount:

[Error] prueba_error.xml:7:36: Element type "from" must be declared.
[Error] prueba_error.xml:7:36: Attribute "url" must be declared for 
element type "from".
[Error] prueba_error.xml:8:19: The content of element type 
"profileRequest" must match "(from)".

and this is the xml file prueba_error.xml:

---------

<?xml version="1.0"?>

<profileRequest xmlns="http://aries.dif.um.es/sipc"
		xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
		xsi:schemaLocation="http://aries.dif.um.es/sipc
		sipc.xsd">
	<from url="http://www.acme.com" />
</profileRequest>

(sorry for the stupid example :)

---------

I hope someone can help me.

Thank you in advance, EMG.
-- 
------------------------------------------------------------------------
Quod scripsi, scripsi
------------------------------------------------------------------------
Eduardo Martinez Gracia
Departamento de Informatica, Inteligencia Artificial y Electronica
Tlf: 34 968364666			Fax: 34 968364151
email: edumart@um.es			http://intelec.dif.um.es
Facultad de Informatica. Campus de Espinardo.
Universidad de Murcia. 30100 Murcia.
------------------------------------------------------------------------

Re: Local and global schema declarations

Posted by Eric Ye <er...@locus.apache.org>.
Yes, 1.2.3 support local element decl.

You are getting the error because in your xml file.  "<from .." is not
resolved as a locally scoped element that has a unqualified name "from" as
the one defined in your schema, to solve this, you can do one of the
following:

1. use a  prefix in the xml file:
 <ppp:profileRequest xmlns:ppp="http://aries.dif.um.es/sipc"
 xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
 xsi:schemaLocation="http://aries.dif.um.es/sipc
 sipc.xsd">
     <from url="http://www.acme.com" />
 </ppp:profileRequest>

2. when defining the "from" local element, set " form='qualified' "

There were lots of discussions regarding  in list archive.
_____


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

----- Original Message -----
From: "Eduardo Martinez Gracia" <ed...@um.es>
To: <xe...@xml.apache.org>
Sent: Thursday, January 18, 2001 3:15 AM
Subject: Local and global schema declarations


> Does xerces 1.2.3 support local element declarations in shemas?
>
> I have the following schema, with a 'from' element declared globally,
> that works fine:
>
> ----------sipc.xsd
> <?xml version="1.0"?>
> <schema targetNamespace="http://aries.dif.um.es/sipc"
> xmlns="http://www.w3.org/1999/XMLSchema"
> xmlns:sipc="http://aries.dif.um.es/sipc">
>
> <element name="profileRequest">
> <complexType>
> <element ref="sipc:from" />
> </complexType>
> </element>
>
> <element name="from">
> <complexType content="empty">
> <attribute name="url"
> type="uriReference" default="http://"/>
> </complexType>
> </element>
>
> </schema>
> ----------
>
> If I use this other schema, with a local declaration of the 'from'
> element, the parsing fails:
>
> ----------
> <?xml version="1.0"?>
> <schema targetNamespace="http://aries.dif.um.es/sipc"
> xmlns="http://www.w3.org/1999/XMLSchema"
> xmlns:sipc="http://aries.dif.um.es/sipc">
>
> <element name="profileRequest">
> <complexType>
> <element name="from">
> <complexType content="empty">
>   <attribute name="url"
>     type="uriReference" default="http://"/>
> </complexType>
> </element>
> </complexType>
> </element>
>
> </schema>
> ---------
>
> This is the error message given by dom.DOMCount:
>
> [Error] prueba_error.xml:7:36: Element type "from" must be declared.
> [Error] prueba_error.xml:7:36: Attribute "url" must be declared for
> element type "from".
> [Error] prueba_error.xml:8:19: The content of element type
> "profileRequest" must match "(from)".
>
> and this is the xml file prueba_error.xml:
>
> ---------
>
> <?xml version="1.0"?>
>
> <profileRequest xmlns="http://aries.dif.um.es/sipc"
> xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
> xsi:schemaLocation="http://aries.dif.um.es/sipc
> sipc.xsd">
> <from url="http://www.acme.com" />
> </profileRequest>
>
> (sorry for the stupid example :)
>
> ---------
>
> I hope someone can help me.
>
> Thank you in advance, EMG.
> --
> ------------------------------------------------------------------------
> Quod scripsi, scripsi
> ------------------------------------------------------------------------
> Eduardo Martinez Gracia
> Departamento de Informatica, Inteligencia Artificial y Electronica
> Tlf: 34 968364666 Fax: 34 968364151
> email: edumart@um.es http://intelec.dif.um.es
> Facultad de Informatica. Campus de Espinardo.
> Universidad de Murcia. 30100 Murcia.
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>


Re: Local and global schema declarations

Posted by Ian Roberts <ir...@decisionsoft.com>.
On Thu, 18 Jan 2001, Eduardo Martinez Gracia wrote:

> <?xml version="1.0"?>
> <schema targetNamespace="http://aries.dif.um.es/sipc"
> 		xmlns="http://www.w3.org/1999/XMLSchema"
> 		xmlns:sipc="http://aries.dif.um.es/sipc">
> 
> <element name="profileRequest">
> 	<complexType>
> 		<element name="from">
> 			<complexType content="empty">
> 			  <attribute name="url" 
> 			    type="uriReference" default="http://"/>
> 			</complexType>
> 		</element>
> 	</complexType>
> </element>
> 
> </schema>

You need to add the attribute:

elementFormDefault="qualified"

to the <schema> element.  Without it, the from element is assumed to be in
the null namespace, which is why the validation was failing.

Ian

-- 
Ian Roberts                     | irr@decisionsoft.com
DecisionSoft Ltd.               | http://www.decisionsoft.com/