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 8652689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:21:58+00:00 2026-06-12T14:21:58+00:00

I have two xsd files. 1st file is common.xsd and the other is node.xsd

  • 0

I have two xsd files. 1st file is common.xsd and the other is node.xsd. Both node.xsd and common.xsd share the same targetNamespace. common.xsd references an element defined in node.xsd using ref attribute. However, node.xsd is NOT included in common.xsd either using include or import. But the XML that I validate using these xsd files, passes the validation (Tried all corner usecases).

I wonder how this is possible. Is this because, they share the same namespace? Also is referencing an element without including/importing legal in XSD?

EDIT:

Simplified Code Snippets(The actual xsd’s are much more complex and they are written in this format for bigger reason):

common.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:my="my-namespace"
        xmlns:xml="http://www.w3.org/XML/1998/namespace"
        targetNamespace="my-namespace"
        elementFormDefault="qualified">
  <xsd:element name="common" type="my:commonType" />
  <xsd:complexType name="commonType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
      <xsd:element ref="my:node"/>
      <!-- few other elements -->
    </xsd:choice>
  </xsd:complexType>
</xsd:schema>

node.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:my="my-namespace"
        xmlns:xml="http://www.w3.org/XML/1998/namespace"
        targetNamespace="my-namespace"
        elementFormDefault="qualified">
  <xsd:include schemaLocation=common.xsd"/>
  <xsd:element name="node" type="my:nodeType"
           substitutionGroup="my:common" />
  <xsd:complexType name="nodeType">
    <xsd:complexContent>
      <xsd:extension base="my:commonType">
        <!-- some 5-7 attributes -->
        <xsd:anyAttribute/>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>
</xsd:schema>

These xsd’s let me nest element within itself any number of times.
E.g

<my:node>
  <my:node />
  <my:node>
    <my:node />
  </my:node>
</my:node>

You can observe that my:node is referenced in common.xsd without including node.xsd. (Curious as to how this even works.)

  • 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-06-12T14:21:59+00:00Added an answer on June 12, 2026 at 2:21 pm

    I can make this look even more wicked… You can remove the xsd:include in node.xsd and still validate your XML! Take a look at this Xerces API for how you could do it.

    The idea is that from a spec perspective, an XML Schema processor can resolve schema locations in many ways. It also means that some XSD files when looked at individually may not be valid due to dangling references, yet when put together through APIs like the one above, or custom resolvers (e.g. supporting “catalog” files) the result is an equivalent schema that is valid.

    The way an XSD processor typically works, is that it puts together all the schema components that can be loaded through the references it can resolve, then it looks at the result as a whole, irrespective of where these components come from. In your case, node.xsd brings in common.xsd; the result is a valid schema, since all that is needed for components in common.xsd can be found among components already brought in by node.xsd.

    In your case it is as if the inner content of the xsd:schema tag in common.xsd replaces the xsd:include in node.xsd. If you do that by hand, the result is correct, right?

    As I side note, I would point out that the snippets you’ve shown don’t illustrate the use of the common substitution group. As a reminder, you have to reference the head of the substitution group if you want you to get substitution going.

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

Sidebar

Related Questions

I have created two wsdl files with shared types imported from xsd schema file.
I have two xml files and I need to create one xsd for both.
I have two xsd files: base.xsd : <schema targetNamespace=http://www.myorg.com/base elementFormDefault=qualified attributeFormDefault=unqualified xmlns=http://www.w3.org/2001/XMLSchema> ... <complexType
I have two files: A sample XML file. A .xsd file w/ schema, which
I have a basic.xsd and two other A.xsd and B.xsd . A.xsd and B.xsd
I have two files client.php and server.php. The client file send a HTTP request
I have two schema files one is imported from the other. When executing the
I have two xsd files to validate a xml. But the problem is my
I have an XSD package composed of two XSD files: let's say A.xsd and
I have two XML files with two different XSD schemas and different namespaces. They

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.