XSchema: help

Discussion in 'XML' started by Tjerk Wolterink, Sep 1, 2005.

  1. I have an schema, like this one:

    <xsd:schema
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:x="http://www.wolterinkwebdesign.com/xml/model"
    xmlns="http://www.wolterinkwebdesign.com/xml/structure"
    targetNamespace="http://www.wolterinkwebdesign.com/xml/structure"
    version="1.0">

    <xsd:element name="structure">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element ref="metadata"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    <xsd:element name="metadata">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="author" type="xsd:string"/>
    <xsd:element name="keywords" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>

    </xsd:schema>


    and a document like this one:

    <structure
    xmlns="http://www.wolterinkwebdesign.com/xml/structure"
    xmlns:x="http://www.wolterinkwebdesign.com/xml/model"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.wolterinkwebdesign.com/xml/structure
    ../schemas/structure.xsd">

    <metadata>
    <title>XCM Test</title>
    <author>Tjerk Wolterink</author>
    <keywords>xcm test</keywords>
    </metadata>
    </structure>



    When i try to validate i get this:

    Xerces Java 2 Validation Starting.
    file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:18,10:
    (Error) cvc-complex-type.2.4.a: Invalid content starting with element
    'title'. One of '{"":title}' is expected.

    huh title is in the namespace of /xml/structure

    file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:41,11:
    (Error) cvc-complex-type.2.4.a: Invalid content starting with element
    'title'. One of '{"":title}' is expected.
    Xerces Java 2 Validation Complete.



    help me
     
    Tjerk Wolterink, Sep 1, 2005
    #1
    1. Advertisements

  2. Tjerk Wolterink

    Soren Kuula Guest

    Hi,

    > file:///d:/development/webapps/XCManager/web/WEB-INF/structure.xml:18,10:
    > (Error) cvc-complex-type.2.4.a: Invalid content starting with element
    > 'title'. One of '{"":title}' is expected.


    It says: I want the title element in no-namespace land.

    Why ?? Because of a really really silly feature i XSD: Locally declared
    elements, such as your title one, slip out of the target namespace and
    into no-namespace-land, unless you add an attribute

    elementFormDefault="qualified"

    to the schema document element (<xsd:schema .......>).

    Alternatively, you can alter to:

    <xsd:sequence>
    <xsd:element name="title" type="xsd:string"
    form="qualified"/>
    <xsd:element name="author" type="xsd:string"
    form="qualified"/>
    <xsd:element name="keywords" type="xsd:string"
    form="qualified"/>
    </xsd:sequence>

    in your schema...


    (don't try looking in the Schema recommendation for where this is said.
    It's totally unreadable :))

    Søren
     
    Soren Kuula, Sep 1, 2005
    #2
    1. Advertisements

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. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    994
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Harvey
    Replies:
    0
    Views:
    1,080
    Harvey
    Jul 16, 2004
  3. Harvey
    Replies:
    1
    Views:
    1,161
    Daniel
    Jul 16, 2004
  4. Karl
    Replies:
    3
    Views:
    464
  5. Binesh Bannerjee
    Replies:
    3
    Views:
    1,817
    Martin Honnen
    Nov 27, 2004
  6. Tjerk Wolterink

    xschema: problem

    Tjerk Wolterink, Sep 1, 2005, in forum: XML
    Replies:
    0
    Views:
    475
    Tjerk Wolterink
    Sep 1, 2005
  7. Tjerk Wolterink

    XInclude and XSchema

    Tjerk Wolterink, Oct 11, 2005, in forum: XML
    Replies:
    9
    Views:
    2,188
    Tjerk Wolterink
    Oct 13, 2005
  8. Tjerk Wolterink

    XSchema Problem with xs:any

    Tjerk Wolterink, Oct 27, 2005, in forum: XML
    Replies:
    2
    Views:
    8,033
    Tjerk Wolterink
    Oct 27, 2005
Loading...