Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when I am validating the XML with XSD I got the following errors.I dont know what wrong in my code.

Could not find schema information for the attribute
Could not find schema information for the element
Could not find schema information for the element
Could not find schema information for the element
Could not find schema information for the element

my C# code

C#
XmlReaderSettings settings = new XmlReaderSettings();
settings.ValidationType = ValidationType.Schema;
settings.Schemas.Add(null, xsdFilePath);
settings.Schemas.Add(null, xsdFilePath1);
settings.Schemas.Add(null, xsdFilePath2);
settings.Schemas.Add(null, xsdFilePath3);
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessInlineSchema;
settings.ValidationFlags |= XmlSchemaValidationFlags.ProcessSchemaLocation;
settings.ValidationFlags |= XmlSchemaValidationFlags.ReportValidationWarnings;
settings.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
XmlReader reader = XmlReader.Create(xmlFilePath, settings);
while (reader.Read()) ;



My XML
XML
<root>
    <firstchild>
        <first name="">
            <br mode="hold" />
            <last name=""> </last>
            <br mode="hold" />
            <address> </address>
      </first>
    </firstchild>
    <second child="">
        <report>
            <tin> </tin>
            <name> <name>
            </name></name>
        </report>
    </second>br mode="hold" />
</root>


My XSD
XML
<xsd:schema xmlns:ftc="urn:oecd:ties:fatca:v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sfa="urn:oecd:ties:stffatcatypes:v1" xmlns:iso="urn:oecd:ties:isofatcatypes:v1" targetnamespace="urn:oecd:ties:fatca:v1" elementformdefault="qualified" attributeformdefault="unqualified" version="1.1">

<xsd:import namespace="urn:oecd:ties:isofatcatypes:v1" schemalocation="isofatcatypes_v1.0.xsd" />

<xsd:import namespace="urn:oecd:ties:stffatcatypes:v1" schemalocation="stffatcatypes_v1.1.xsd" /></xsd:schema>
Posted
Updated 28-Oct-14 19:11pm
v7
Comments
George Jonsson 29-Oct-14 1:16am    
I tried to format the XML so it is readable, but it has a very strange structure.
Is this really what you have? Or did I format it wrong?

The schema doesn't tell us anything as you import the actual definitions from other schemas.

1 solution

There's nothing wrong in your code (o the first look). There is something wrong in your xml file.

Please, read this: Working with Namespaces in XML Schema[^]. It might help you to resolve your issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900