Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   putting together 2 XSD (http://www.velocityreviews.com/forums/t485857-putting-together-2-xsd.html)

Xh 03-21-2007 02:35 AM

putting together 2 XSD
 
Hi All!

I have two simple XSD files

they are used for elements: <patient> and <address>

as standalone XML schemas - they work perfectly - validated with:
http://validate.openlaboratory.net/

I tried to put them together but they don't work.

I got errors with element <address> - maybe I'm missing something
or my XML document is invalid in a way I don't see or understand?

I got message: Element 'address' is not valid for content model:
'((lastName,birthDate),address)'

My document looks like this:

<p:patient xmlns:p="http://test/patient" xmlns:a="http://test/
address">
<p:lastName>test</p:lastName><p:birthDate>1983-03-07</p:birthDate>
<a:address>
<a:postalCode>01-111</a:postalCode>
<a:city>Wasas</a:city>
<a:street>dsdsd</a:street>
<a:country>Poland</a:country>
</a:address>
</p:patient>

This is for patient:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/patient"
xmlns="http://test/patient"
xmlns:addr="http://test/address"
elementFormDefault="qualified">
<xs:import namespace="http://test/address"/>
<xs:element name="patient" type="patientType"/>
<xs:element name="lastName" type="xs:string"/>
<xs:element name="birthDate" type="xs:date"/>
<xs:element name="address" type="addr:addressType"/>
<xs:complexType name="patientType">
<xs:sequence>
<xs:element ref="lastName"/>
<xs:element ref="birthDate"/>
<xs:element ref="address"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

and this is finally the address.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://test/address"
xmlns="http://test/address">
<xs:element name="address" type="addressType"/>
<xs:element name="postalCode" type="postalCodeType"/>
<xs:element name="city" type="stringMinLenght3"/>
<xs:element name="street" type="stringMinLenght3"/>
<xs:element name="country" type="stringMinLenght3"/>
<xs:simpleType name="stringMinLenght3">
<xs:restriction base="xs:string">
<xs:minLength value="3"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="postalCodeType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{2}-[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="addressType">
<xs:sequence>
<xs:element ref="postalCode"/>
<xs:element ref="city"/>
<xs:element ref="street"/>
<xs:element ref="country"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

thanks in advance for any tips and hints

best regards
Ɓukasz


p.lepin@ctncorp.com 03-21-2007 08:36 AM

Re: putting together 2 XSD
 
On Mar 21, 4:35 am, "Xh"
<lukasz.bud...@komputery-internet.net> wrote:
> I have two simple XSD files
> they are used for elements: <patient> and <address>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="http://test/patient"
> xmlns="http://test/patient"
> xmlns:addr="http://test/address"
> elementFormDefault="qualified">
> <xs:import namespace="http://test/address"/>


You seem to be missing something here (and that something
seems to be the schemaLocation attribute).

> <xs:element name="patient" type="patientType"/>
> <xs:element name="lastName" type="xs:string"/>
> <xs:element name="birthDate" type="xs:date"/>
> <xs:element name="address" type="addr:addressType"/>


Absolutely no reason to do this.

> <xs:complexType name="patientType">
> <xs:sequence>
> <xs:element ref="lastName"/>
> <xs:element ref="birthDate"/>
> <xs:element ref="address"/>


<xs:element ref="addr:address"/>, since you're trying to
import it anyway.

> </xs:sequence>
> </xs:complexType>
> </xs:schema>


There might be other problems with your schemata, too, but
this should solve your immediate problem.

--
Pavel Lepin



All times are GMT. The time now is 04:30 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.