XML Schema validation problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joukoik
    New Member
    • Mar 2012
    • 2

    XML Schema validation problem

    Hey, I have a little problem in my XML Schema that ive been thinking for some time but as a beginner I think it would be better that I ask opinions from experts.

    So I have this simple xsd file
    Code:
    <?xml version="1.0"  encoding="utf-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
    <xs:complexType name="Henkilokunta">
    <xs:sequence>
    	  <xs:element name="tiskaus" type="xs:string"/>
          <xs:element name="kokki" type="xs:string"/>
          <xs:element name="tarjoilija" type="xs:string"/>
    	  <xs:element name="Keittio" type="xs:string"/>
          <xs:element name="sihteeri" type="xs:string"/>
    	  <xs:element name="Toimisto" type="xs:string"/>
    	  <xs:element name="siivooja" type="xs:string"/>
    	  <xs:element name="huoltomies" type="xs:string"/>
    	  <xs:element name="Kiinteistohuolto" type="xs:string"/>
    	  <xs:element name="IT-tuki" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    
    <xs:element name="Henkilokunta" type="xs:string"/>
    </xs:schema>
    And after some time of work I managed to leave only 1 error, which is following:

    cvc-type.3.1.2: Element 'Henkilokunta' is a simple type, so it must have no element information item [children].

    I dont understand the problem, because 'Henkilokunta' is my root element.
    Last edited by Joukoik; Mar 23 '12, 03:25 PM. Reason: I worked it a little bit after posting the original and now I have a new problem
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    After looking at the xsd (and consulting http://www.w3schools.com/schema/schema_howto.asp), i would do this:
    Try changing your xsd to:
    Code:
    <?xml version="1.0"  encoding="utf-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
     
    <xs:element name="Henkilokunta">
    <xs:complexType>
    <xs:sequence>
          <xs:element name="tiskaus" type="xs:string"/>
          <xs:element name="kokki" type="xs:string"/>
          <xs:element name="tarjoilija" type="xs:string"/>
          <xs:element name="Keittio" type="xs:string"/>
          <xs:element name="sihteeri" type="xs:string"/>
          <xs:element name="Toimisto" type="xs:string"/>
          <xs:element name="siivooja" type="xs:string"/>
          <xs:element name="huoltomies" type="xs:string"/>
          <xs:element name="Kiinteistohuolto" type="xs:string"/>
          <xs:element name="IT-tuki" type="xs:string"/>
        </xs:sequence>
    </xs:complexType>
    </xs:element>
     
    </xs:schema>
    but i'm not an XSD-expert too ;)

    Comment

    • Joukoik
      New Member
      • Mar 2012
      • 2

      #3
      Thank you for responding, but changing this gave me a couple more problems. So my xsd looks exactly like that now, and the errors are following:

      cvc-complex-type.2.4.a: Invalid content was found starting with element 'Keittio'. One of '{tiskaus}' is expected.

      cvc-type.3.1.2: Element 'Keittio' is a simple type, so it must have no element information item [children].

      cvc-type.3.1.2: Element 'Toimisto' is a simple type, so it must have no element information item [children].

      and same thing with element 'Kiinteistohuol to'

      why it says they are simple type?

      EDIT: I added this in the beginning and now I have 1 error again.


      <?xml version="1.0"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      targetNamespace ="http://www.w3schools.c om"
      xmlns="http://www.w3schools.c om"
      elementFormDefa ult="qualified" >

      the error is following:

      cvc-elt.1.a: Cannot find the declaration of element 'Henkilokunta'

      Confused again, as always
      Last edited by Joukoik; Mar 23 '12, 09:33 PM. Reason: I worked on the document more and now I have new problem

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        Thank you for responding, but changing this gave me a couple more problems. So my xsd looks exactly like that now, and the errors are following:

        cvc-complex-type.2.4.a: Invalid content was found starting with element 'Keittio'. One of '{tiskaus}' is expected.
        so, i think you did not copy it exactly, or made a typing error.....
        EDIT: I added this in the beginning and now I have 1 error again.
        Because it makes no sence putting that at the beginning. Now it only shows 1 error because it does not understand the rest of your XSD...

        Confused again, as always
        Confused /me is to.....

        Comment

        Working...