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. Advertising

  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. 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. Karl
    Replies:
    3
    Views:
    356
  2. Binesh Bannerjee
    Replies:
    3
    Views:
    1,647
    Martin Honnen
    Nov 27, 2004
  3. Tjerk Wolterink

    xschema: problem

    Tjerk Wolterink, Sep 1, 2005, in forum: XML
    Replies:
    0
    Views:
    407
    Tjerk Wolterink
    Sep 1, 2005
  4. Tjerk Wolterink

    XInclude and XSchema

    Tjerk Wolterink, Oct 11, 2005, in forum: XML
    Replies:
    9
    Views:
    1,766
    Tjerk Wolterink
    Oct 13, 2005
  5. Tjerk Wolterink

    XSchema Problem with xs:any

    Tjerk Wolterink, Oct 27, 2005, in forum: XML
    Replies:
    2
    Views:
    7,808
    Tjerk Wolterink
    Oct 27, 2005
Loading...

Share This Page