X
Xh
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
atient xmlns
="http://test/patient" xmlns:a="http://test/
address">
<p:lastName>test</p:lastName><p:birthDate>1983-03-07</p:birthDate>
<a:address>
<a
ostalCode>01-111</a
ostalCode>
<a:city>Wasas</a:city>
<a:street>dsdsd</a:street>
<a:country>Poland</a:country>
</a:address>
</p
atient>
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
attern 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
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
address">
<p:lastName>test</p:lastName><p:birthDate>1983-03-07</p:birthDate>
<a:address>
<a
<a:city>Wasas</a:city>
<a:street>dsdsd</a:street>
<a:country>Poland</a:country>
</a:address>
</p
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
</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