0

XSD schema saying:

Line: 2, Position: 2 "Could not find schema information for the element 'ArrayOfClient'."
Line: 3, Position: 4 "Could not find schema information for the element 'Client'."
Line: 3, Position: 11 "Could not find schema information for the attribute 'ID'."
Line: 3, Position: 27 "Could not find schema information for the attribute 'email'."

XSD schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
    targetNamespace="http://tempuri.org/XMLSchema1.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/XMLSchema1.xsd"
    xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:simpleType name="stringtype">
    <xs:restriction base="xs:string"/>
  </xs:simpleType>

  <xs:complexType name="clientType">
    <xs:attribute name="ID"     type="stringtype" use="required"/>
    <xs:attribute name="email"  type="stringtype" use="required"/>
  </xs:complexType>

  <xs:complexType name="ClientsType">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Client" type="clientType" />
    </xs:sequence>
  </xs:complexType>

  <xs:element name="ArrayOfClient" type="ClientsType"/>
</xs:schema>

XML file:

<?xml version="1.0"?>
<ArrayOfClient xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Client ID="00000000" email="user@mail.com" />
</ArrayOfClient>
  1. This doesn't work, the xml file is generated with XmlSerializer from .NET C#.
  2. Is there a way I can impose a verification for the ID attribute so it will always be a number of 10 digits and email... ?

Edit: Further information on the way I build the XML file here.

Community
  • 1
  • 1
AlexandruC
  • 3,527
  • 6
  • 51
  • 80

1 Answers1

1

You're missing the xmlns which should be http://tempuri.org/XMLSchema1.xsd, i.e. your ArrayOfClient should have an attribute such as xmlns="http://tempuri.org/XMLSchema1.xsd"

The example you're pointing at doesn't make use of XML namespaces. I recommend to simply run xsd.exe /c your.xsd and have a look at the generated classes. You'll see exactly what differences you're missing.

Petru Gardea
  • 21,373
  • 2
  • 50
  • 62
  • Salutare! It is generated from within c#, either there is an option for XmlSerializer to do this or I modify the XSD – AlexandruC Oct 22 '13 at 16:09
  • @A.K... Salutare :)... Have a look [here](http://stackoverflow.com/questions/15809868/how-to-add-xsi-schemalocation-to-root-c-object-xmlserializer/15960370#15960370) - there's a lot you can do with customizations... also see if the partial class answer applies to your case. – Petru Gardea Oct 22 '13 at 16:47
  • http://stackoverflow.com/questions/19548443/bind-any-xml-xsd-to-datagridview-c-sharp from your experience, is there any way to do that? – AlexandruC Oct 23 '13 at 17:33