putting together 2 XSD

Discussion in 'XML' started by Xh, Mar 21, 2007.

  1. Xh

    Xh Guest

    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
    Xh, Mar 21, 2007
    #1
    1. Advertising

  2. Xh

    Guest

    On Mar 21, 4:35 am, "Xh"
    <> 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
    , Mar 21, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Saurabh
    Replies:
    6
    Views:
    4,486
    Chris Smith
    May 30, 2004
  2. Christopher M. Lusardi
    Replies:
    1
    Views:
    344
    Michael Mair
    Nov 16, 2004
  3. Christopher M. Lusardi

    How To Reduce Number Files by Putting file1.c and file2.C Together

    Christopher M. Lusardi, Nov 16, 2004, in forum: C Programming
    Replies:
    1
    Views:
    307
    Michael Mair
    Nov 16, 2004
  4. Matjaz Bezovnik
    Replies:
    4
    Views:
    290
    Robert Kern
    Aug 25, 2009
  5. CBlair1986
    Replies:
    4
    Views:
    125
    CBlair1986
    Nov 18, 2006
Loading...

Share This Page