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

  • SEARCH
  • Home
  • 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 6738583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:23:10+00:00 2026-05-26T11:23:10+00:00

I am working on a code that is trying to read in a bunch

  • 0

I am working on a code that is trying to read in a bunch of xsd files and compiling schemas in a XmlSchemaSet.

Problem is that these xsd files come from various sources, and they might have elements/types declared multiple times, which i should remove or else i the compile method of XmlSchemaSet would throw an error.

Is there a recommended way of doing this type of thing ?

  • 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-26T11:23:10+00:00Added an answer on May 26, 2026 at 11:23 am

    I followed steps from this MSDN post and it worked for me:

    http://social.msdn.microsoft.com/Forums/en-US/xmlandnetfx/thread/7f1b7307-98c8-4457-b02b-1e6fa2c63719/

    The basic idea is to go through the types from the new schema and remove them from that schema if they exist in the existing schema.

     class Program
      {
        static void Main(string[] args)
        {
          XmlSchemaSet schemaSet = MergeSchemas(@"..\..\XMLSchema1.xsd", @"..\..\XMLSchema2.xsd");
          foreach (XmlSchema schema in schemaSet.Schemas())
          {
            schema.Write(Console.Out);
            Console.WriteLine();
          }
        }
    
        public static XmlSchemaSet MergeSchemas(string schema1, string schema2)
        {
          XmlSchemaSet schemaSet1 = new XmlSchemaSet();
          schemaSet1.Add(null, schema1);
          schemaSet1.Compile();
    
          XmlSchemaSet schemaSet2 = new XmlSchemaSet();
          schemaSet2.Add(null, schema2);
          schemaSet2.Compile();
    
          foreach (XmlSchemaElement el1 in schemaSet1.GlobalElements.Values)
          {
            foreach (XmlSchemaElement el2 in schemaSet2.GlobalElements.Values)
            {
              if (el2.QualifiedName.Equals(el1.QualifiedName))
              {
                ((XmlSchema)el2.Parent).Items.Remove(el2);
                break;
              }
            }
          }
          foreach (XmlSchema schema in schemaSet2.Schemas())
          {
            schemaSet2.Reprocess(schema);
          }
          schemaSet2.Compile();
          schemaSet1.Add(schemaSet2);
    
          return schemaSet1;
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get some code working that a previous developer has written. Yep,
I'm working on a piece of code that I inherited and am trying to
Im trying to read in image file from a server , with the code
I'm trying to simulate some code that I have working with SQL but using
I am trying to read a file located at C:\Users\Siddharth\Documents\aarti\yeh_vidhi_mangal.txt. Following code indicates that
I'm trying to use java to read a string from a file that was
I'm working on code that does nearest-neighbor queries. There are two simple ideas that
I'm working on code that's supposed to start the screensaver defined by the user
I've recently been working with code that looks like this: using namespace std; class
I'm working on some code that uses the System.Diagnostics.Trace class and I'm wondering how

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.