Include statement, it drives me nuts!

Discussion in 'XML' started by Karl, May 26, 2004.

  1. Karl

    Karl Guest

    Hi!

    I'm trying with a really simple test, to use a schema within another, but
    xmlspy keeps giving me error message: Schema Error - undefined value for
    'type' encountered!

    The file PersonGroup.xsd refuses to validate the Person type, even though
    the include element. I know it finds the Person.xsd file, because I get a
    "not found" error if I change the schemaLocation value. I thought I was
    doing everything by the book, I just cant find the mistake!

    It is as simple as this:

    File: Person.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://www.test.com/schemas"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.test.com/schemas" elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:element name="Person">
    <xs:complexType>
    <xs:sequence>
    <xs:element name="Phonenumber" type="xs:string"/>
    <xs:element name="Firstname" type="xs:string"/>
    <xs:element name="Lastname" type="xs:string"/>
    </xs:sequence>
    <xs:attribute name="Id" type="xs:ID" use="required"/>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    File: PersonGroup.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://www.test.com/schemas"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns="http://www.test.com/schemas" elementFormDefault="qualified">
    <xs:include schemaLocation="Person.xsd"/>
    <xs:element name="PersonGroup">
    <xs:complexType>
    <xs:sequence maxOccurs="unbounded">
    <xs:element name="Name"/>
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="aPerson" type="Person" />
    <xs:element name="PersonId" type="xs:IDREF"/>
    </xs:choice>
    </xs:sequence>
    </xs:complexType>
    </xs:element>
    </xs:schema>

    regards

    Karl Z
     
    Karl, May 26, 2004
    #1
    1. Advertising

  2. Hi,

    The "type" attribute has to refer to a type (complex or simple). Your
    "Person" defined in the included schema is an element, not a type. You
    should either change it to:

    element ref="Person"

    or make Person a complex type rather than an element.

    Hope that helps,
    Priscilla

    -----------------------------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema (Prentice Hall PTR)
    -----------------------------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Priscilla Walmsley, May 26, 2004
    #2
    1. Advertising

  3. Karl

    Karl Guest

    Hi again!

    Yes, it helped, now I can reference the schemas from each other!

    Unfortunately, I got another very strange problem, when I try to use the
    simple schema, person.xsd.

    Xmlspy gives me "No content model available for validation (possible empty
    DTD/Schema)", in the Person.xsd when I try to save my test.xml file, which
    is very simple indeed:

    Test.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <Person xmlns="http://www.test.com/schemas"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.test.com/schemas
    C:\vcs\Source\Import_export_formats\Schemas\Person.xsd">
    </Person>

    Person.xsd
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema targetNamespace="http://www.test.com/schemas"
    xmlns="http://www.test.com/schemas"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
    attributeFormDefault="unqualified">
    <xs:complexType name="Person">
    <xs:sequence>
    <xs:element name="Phonenumber" type="xs:string"/>
    <xs:element name="Firstname" type="xs:string"/>
    <xs:element name="Lastname" type="xs:string"/>
    </xs:sequence>
    <xs:attribute name="Id" type="xs:ID" use="required"/>
    </xs:complexType>
    </xs:schema>

    Is there something obvious I've missed?

    regards

    Karl Z

    "Priscilla Walmsley" <> wrote in message
    news:40b5173c$0$209$...
    > Hi,
    >
    > The "type" attribute has to refer to a type (complex or simple). Your
    > "Person" defined in the included schema is an element, not a type. You
    > should either change it to:
    >
    > element ref="Person"
    >
    > or make Person a complex type rather than an element.
    >
    > Hope that helps,
    > Priscilla
    >
    > -----------------------------------------------------
    > Priscilla Walmsley
    > Author, Definitive XML Schema (Prentice Hall PTR)
    > -----------------------------------------------------
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Karl, May 27, 2004
    #3
  4. Hi,

    Yes, you do also need to have an element named Person. In the first
    example you gave me, the Person element was declared in your other
    schema. In this case, the Person element is not declared anywhere.

    If you add:

    <xs:element name="Person" type="Person"/>

    it should work.

    Priscilla

    -----------------------------------------------------
    Priscilla Walmsley
    Author, Definitive XML Schema (Prentice Hall PTR)
    -----------------------------------------------------

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Priscilla Walmsley, May 27, 2004
    #4
  5. Karl

    Karl Guest

    It did the trick! Thanks a lot!

    "Priscilla Walmsley" <> wrote in message
    news:40b5ce06$0$204$...
    > Hi,
    >
    > Yes, you do also need to have an element named Person. In the first
    > example you gave me, the Person element was declared in your other
    > schema. In this case, the Person element is not declared anywhere.
    >
    > If you add:
    >
    > <xs:element name="Person" type="Person"/>
    >
    > it should work.
    >
    > Priscilla
    >
    > -----------------------------------------------------
    > Priscilla Walmsley
    > Author, Definitive XML Schema (Prentice Hall PTR)
    > -----------------------------------------------------
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Karl, May 27, 2004
    #5
    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. bob

    format driving me nuts

    bob, Jul 15, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    405
  2. Kathy Burke
    Replies:
    6
    Views:
    656
    Munsifali Rashid
    Aug 13, 2003
  3. =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=

    Enumerate all the drives including Mapped network drives on a serv

    =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=, Feb 25, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,058
    =?Utf-8?B?UHJhZGVlcCBTdW5kYXJhbShNU0ZUKQ==?=
    Feb 26, 2005
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    1,003
    Andreas Bogenberger
    Feb 22, 2008
  5. Anthony Smith

    If statement issue driving me nuts

    Anthony Smith, Apr 6, 2014, in forum: Python
    Replies:
    2
    Views:
    91
    Gary Herron
    Apr 6, 2014
Loading...

Share This Page