0

I am very new to both XML and XSD. I am given an XSD file and need to generate an XML file based on that schema. My XSD file looks like this.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://collegeboard.org/CommonImport" targetNamespace="http://collegeboard.org/CommonImport" elementFormDefault="qualified" version="2.0">

 <xs:complexType name="StudentType">
 <xs:all>
  <xs:element name="StudentID" type="StudentIDType" nillable="false"/>
  <xs:element name="StudentName" type="StudentNameType" nillable="true" minOccurs="0"/>
 </xs:all> 
</xs:complexType>

<xs:element name="CommonImport">
 <xs:complexType mixed="true">
  <xs:sequence>
    <xs:element name="Student" type="StudentType" maxOccurs="10000"/>
  </xs:sequence>
    <xs:attribute name="StudentRecordCount" type="xs:int" use="required"/>
  </xs:complexType>
 </xs:element>
</xs:schema>

This is the XML file that I came up with.

<?xml version="1.0" encoding="UTF-8"?>
<CommonImport xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://collegeboard.org/CommonImport" StudentRecordCount ="1116">
 <Student> 
  <StudentNameType LastName="Tin" FirstName="Jon" MiddleInitial="A" />
  <AwardYearTokenType>2099</AwardYearTokenType>
  <AddressType Street1="1234 Broadway Ave" />
 </Student>
</CommonImport>

I am getting an error of "Invalid content was found starting with element 'StudentNameType'. One of '{"http://collegeboard.org/CommonImport":StudentID}" is expected." I don't know how to fix this. Any help is appreciated.

Thank you.

pseudo
  • 385
  • 2
  • 19
  • Read your schema. It says that the element *name* is `StudentType`, and it is of *type StudentNameType*. Read those words carefully, and you should be able to see the problem. – Ken White Feb 17 '15 at 22:48
  • Where are you declared `AwardYearTokenType` and `AddressType` element? – Xstian Feb 18 '15 at 11:26

0 Answers0