Cannot create a valid instance from my schema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wooks

    #1

    Cannot create a valid instance from my schema

    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:de fineApplication "
    xmlns="urn:fast er:defineApplic ation"
    elementFormDefa ult="qualified" >
    <xsd:simpleTy pe name="entityNam eType">
    <xsd:restrictio n base="xsd:NCNam e">
    <!-- defines alphanumeric field that contains at least 1 alpha-->
    <xsd:pattern value="\p{L}\w* "/>
    </xsd:restriction >
    </xsd:simpleType>
    <xsd:complexTyp e name="interface " abstract="true" >
    <xsd:sequence >
    <xsd:any namespace="##lo cal" processContents ="lax" />
    </xsd:sequence>
    </xsd:complexType >
    <xsd:complexTyp e name="appInterf ace">
    <xsd:complexCon tent>
    <xsd:extensio n base="interface ">
    <xsd:sequence >
    <xsd:element ref="appFrame"/>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexCont ent>
    </xsd:complexType >
    <xsd:complexTyp e name="frameInte rface" abstract="true"/>
    <xsd:complexTyp e name="appFrame" >
    <xsd:complexCon tent>
    <xsd:extensio n base="interface ">
    <xsd:sequence >
    <xsd:element ref="name">
    </xsd:element>
    </xsd:sequence>
    </xsd:extension>
    </xsd:complexCont ent>
    </xsd:complexType >
    <xsd:element name="name" type="entityNam eType"/>
    <xsd:element name="appFrame" type="appFrame"/>
    <xsd:element name="root" type="appInterf ace"/>
    </xsd:schema>

    I cannot understand why my instance keeps failing validation

    <?xml version="1.0"?>
    <root xmlns="urn:fast er:defineApplic ation">
    <labels name="Applicati on" 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
  • Martin Honnen

    #2
    Re: Cannot create a valid instance from my schema



    wooks wrote:
    [color=blue]
    > 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:de fineApplication "
    > xmlns="urn:fast er:defineApplic ation"
    > elementFormDefa ult="qualified" >
    > <xsd:simpleTy pe name="entityNam eType">
    > <xsd:restrictio n base="xsd:NCNam e">
    > <!-- defines alphanumeric field that contains at least 1 alpha-->
    > <xsd:pattern value="\p{L}\w* "/>
    > </xsd:restriction >
    > </xsd:simpleType>
    > <xsd:complexTyp e name="interface " abstract="true" >
    > <xsd:sequence >
    > <xsd:any namespace="##lo cal" processContents ="lax" />
    > </xsd:sequence>
    > </xsd:complexType >
    > <xsd:complexTyp e name="appInterf ace">
    > <xsd:complexCon tent>
    > <xsd:extensio n base="interface ">
    > <xsd:sequence >
    > <xsd:element ref="appFrame"/>
    > </xsd:sequence>
    > </xsd:extension>
    > </xsd:complexCont ent>
    > </xsd:complexType >
    > <xsd:complexTyp e name="frameInte rface" abstract="true"/>
    > <xsd:complexTyp e name="appFrame" >
    > <xsd:complexCon tent>
    > <xsd:extensio n base="interface ">
    > <xsd:sequence >
    > <xsd:element ref="name">
    > </xsd:element>
    > </xsd:sequence>
    > </xsd:extension>
    > </xsd:complexCont ent>
    > </xsd:complexType >
    > <xsd:element name="name" type="entityNam eType"/>
    > <xsd:element name="appFrame" type="appFrame"/>
    > <xsd:element name="root" type="appInterf ace"/>
    > </xsd:schema>
    >
    > I cannot understand why my instance keeps failing validation
    >
    > <?xml version="1.0"?>
    > <root xmlns="urn:fast er:defineApplic ation">
    > <labels name="Applicati on" xmlns=""></labels>
    > <name>again</name>
    > </root>
    >
    > I keep getting element content is invalid according to DTD/Schema[/color]

    The following is a valid instance:

    <?xml version="1.0" encoding="UTF-8"?>
    <root xmlns="urn:fast er:defineApplic ation"
    xmlns:xsi="http ://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocat ion="urn:faster :defineApplicat ion test2004081201X sd.xml">
    <labels name="Applicati on" xmlns=""></labels>
    <appFrame>
    <whatever xmlns="">Kibolo gy</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/

    Comment

    Working...