Cannot create a valid instance from my schema

Discussion in 'XML' started by wooks, Aug 12, 2004.

  1. wooks

    wooks Guest

    The schema below describes an interface to a form where the
    appInterface type is an extension of an abstract type called interface
    and it contains an appFrame element that is an extension of an empty
    abstract complex type called frameInterface (the reason for that is so
    that the system will recognise all frames by virtue of their being
    derived from frameInterface type).

    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:faster:defineApplication"
    xmlns="urn:faster:defineApplication"
    elementFormDefault="qualified">
    <xsd:simpleType name="entityNameType">
    <xsd:restriction base="xsd:NCName">
    <!-- defines alphanumeric field that contains at least 1 alpha-->
    <xsd:pattern value="\p{L}\w*"/>
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:complexType name="interface" abstract="true">
    <xsd:sequence>
    <xsd:any namespace="##local" processContents="lax" />
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="appInterface">
    <xsd:complexContent>
    <xsd:extension base="interface">
    <xsd:sequence>
    <xsd:element ref="appFrame"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    <xsd:complexType name="frameInterface" abstract="true"/>
    <xsd:complexType name="appFrame">
    <xsd:complexContent>
    <xsd:extension base="interface">
    <xsd:sequence>
    <xsd:element ref="name">
    </xsd:element>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>
    <xsd:element name="name" type="entityNameType"/>
    <xsd:element name="appFrame" type="appFrame"/>
    <xsd:element name="root" type="appInterface"/>
    </xsd:schema>

    I cannot understand why my instance keeps failing validation

    <?xml version="1.0"?>
    <root xmlns="urn:faster:defineApplication">
    <labels name="Application" xmlns=""></labels>
    <name>again</name>
    </root>

    I keep getting element content is invalid according to DTD/Schema

    I am at my wits end with this so help will be gratefully appreciated
     
    wooks, Aug 12, 2004
    #1
    1. Advertisements

  2. wooks wrote:

    > The schema below describes an interface to a form where the
    > appInterface type is an extension of an abstract type called interface
    > and it contains an appFrame element that is an extension of an empty
    > abstract complex type called frameInterface (the reason for that is so
    > that the system will recognise all frames by virtue of their being
    > derived from frameInterface type).
    >
    > <?xml version="1.0"?>
    > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    > targetNamespace="urn:faster:defineApplication"
    > xmlns="urn:faster:defineApplication"
    > elementFormDefault="qualified">
    > <xsd:simpleType name="entityNameType">
    > <xsd:restriction base="xsd:NCName">
    > <!-- defines alphanumeric field that contains at least 1 alpha-->
    > <xsd:pattern value="\p{L}\w*"/>
    > </xsd:restriction>
    > </xsd:simpleType>
    > <xsd:complexType name="interface" abstract="true">
    > <xsd:sequence>
    > <xsd:any namespace="##local" processContents="lax" />
    > </xsd:sequence>
    > </xsd:complexType>
    > <xsd:complexType name="appInterface">
    > <xsd:complexContent>
    > <xsd:extension base="interface">
    > <xsd:sequence>
    > <xsd:element ref="appFrame"/>
    > </xsd:sequence>
    > </xsd:extension>
    > </xsd:complexContent>
    > </xsd:complexType>
    > <xsd:complexType name="frameInterface" abstract="true"/>
    > <xsd:complexType name="appFrame">
    > <xsd:complexContent>
    > <xsd:extension base="interface">
    > <xsd:sequence>
    > <xsd:element ref="name">
    > </xsd:element>
    > </xsd:sequence>
    > </xsd:extension>
    > </xsd:complexContent>
    > </xsd:complexType>
    > <xsd:element name="name" type="entityNameType"/>
    > <xsd:element name="appFrame" type="appFrame"/>
    > <xsd:element name="root" type="appInterface"/>
    > </xsd:schema>
    >
    > I cannot understand why my instance keeps failing validation
    >
    > <?xml version="1.0"?>
    > <root xmlns="urn:faster:defineApplication">
    > <labels name="Application" xmlns=""></labels>
    > <name>again</name>
    > </root>
    >
    > I keep getting element content is invalid according to DTD/Schema


    The following is a valid instance:

    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns="urn:faster:defineApplication"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:faster:defineApplication test2004081201Xsd.xml">
    <labels name="Application" xmlns=""></labels>
    <appFrame>
    <whatever xmlns="">Kibology</whatever>
    <name>again</name>
    </appFrame>
    </root>

    you need to have an <appFrame> element and have that contain a sequence
    of any element and a <name> element.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Aug 12, 2004
    #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. Roland
    Replies:
    2
    Views:
    3,945
    Roland
    Apr 3, 2005
  2. Markus
    Replies:
    1
    Views:
    1,935
    Markus
    Nov 23, 2005
  3. kelvSYC
    Replies:
    0
    Views:
    416
    kelvSYC
    Nov 11, 2003
  4. Christian Reiser

    Schema for IPv4: valid or not?

    Christian Reiser, Aug 13, 2004, in forum: XML
    Replies:
    0
    Views:
    654
    Christian Reiser
    Aug 13, 2004
  5. Stanimir Stamenkov
    Replies:
    3
    Views:
    1,573
    Stanimir Stamenkov
    Apr 25, 2005
  6. Replies:
    5
    Views:
    1,314
    Harrie
    Nov 23, 2005
  7. Sandra-24
    Replies:
    18
    Views:
    2,295
    Steve Holden
    Apr 29, 2006
  8. Waldy
    Replies:
    4
    Views:
    634
    Waldy
    Aug 3, 2007
Loading...