Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:29:18+00:00 2026-05-25T19:29:18+00:00

I am using a nested XSD schema to validate an XML document. The imported

  • 0

I am using a nested XSD schema to validate an XML document. The imported XSDs use their own target namespaces and I can validate the sample XML given below using Liquid XML Studio. But when I run the validation using my C# code below, it fails with the type declaration error (see below). I have spend alot of time trying to figure out, but no luck:

Main XSD Schema (DataItem.xsd):

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:DataNumeric="Doc.DataNumeric" xmlns:DataYesNo="Doc.DataYesNo"  attributeFormDefault="qualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation="DataNumeric.xsd" namespace="Doc.DataNumeric" />
  <xs:import schemaLocation="DataYesNo.xsd" namespace="Doc.DataYesNo" />
  <xs:complexType name="tDataItem">
      <xs:choice>
        <xs:element name="DataNumeric" type="DataNumeric:tDataNumeric" />
        <xs:element name="DataYesNo" type="DataYesNo:tDataYesNo" />
      </xs:choice>
  </xs:complexType>
  <xs:element name="DataItem" type="tDataItem" />  
</xs:schema>

Included XSD Schema (DataNumeric.xsd):

**<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:DataNumeric="Doc.DataNumeric" elementFormDefault="qualified" targetNamespace="Doc.DataNumeric" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:complexType name="tDataNumeric">
    <xs:sequence>
      <xs:element name="Answer" type="xs:double" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="DataNumeric" type="DataNumeric:tDataNumeric" />
</xs:schema>**

The XML:

<DataItem>
  <DataNumeric xmlns:DataNumeric="Doc.DataNumeric">
    <DataNumeric:Answer>37.8</DataNumeric:Answer>
  </DataNumeric>
</DataItem>

Validation Error:

XmlSchemaValidationException: Type ‘Doc.DataNumeric:tDataNumeric’ is not declared.

C# Validation Code:

XDocument xDoc = XDocument.Parse(xxxxxxx);
string xsdPath = ConfigUtils.GetXsdPath(XsdSchemaIdentifier.HHDataItem);
FileStream fs = new FileStream(xsdPath, FileMode.Open);
XmlReader reader = XmlReader.Create(fs);
XmlSchemaSet xss = new XmlSchemaSet();
xss.Add("", reader);
fs.Close();
fs.Dispose();

xDoc.Validate(xss, null);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:29:19+00:00Added an answer on May 25, 2026 at 7:29 pm

    I have found the problem after a frustrating day and a half of iterations. Changing:

    FileStream fs = new FileStream(xsdPath, FileMode.Open);
    XmlReader reader = XmlReader.Create(fs);
    XmlSchemaSet xss = new XmlSchemaSet();
    xss.Add("", reader);
    

    to

    XmlSchemaSet xss = new XmlSchemaSet();
    xss.Add("", xsdPath);
    

    solved the problem. However I am still looking for the answer to WHY? Both are valid ways of adding a schema to the schema set (i.e. 2 overloads).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PyObjC , you can use Python to write Cocoa applications for OS X.
I'm using OC4J 10.1.3.5.0, and have an issue with the XML namespaces in the
What are the pros and cons of using nested public C++ classes and enumerations?
It is often useful to implement algorithms using nested array operations. For example, to
I am using some nested layouts in Ruby on Rails, and in one of
Right now I am using this to export a repeater (with multiple nested repeaters)
I am using Spring Forms for my web application. For nested properties, the form
How would I create a nested grouping for the table below, using LINQ? I
I have an XSD file and I want to create an XML file at
I'm working in Visual Studio 2008 using c#. Let's say I have 2 xsd

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.