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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:05:15+00:00 2026-06-13T13:05:15+00:00

Now I have an XSD file (e.g. FOO_SCHEMA.xsd) that looks something like this: <xs:schema

  • 0

Now I have an XSD file (e.g. FOO_SCHEMA.xsd) that looks something like this:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="FOO">
        <xs:annotation>
            <xs:documentation>Comment</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element name="BAR1" type="xs:string" />
                <xs:element name="BAR2" type="xs:string" />
                <xs:element name="BAR3" type="xs:string" />
                <xs:element name="BAR4" type="xs:string" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

I want to modify two of the elements (say BAR1 and BAR2) to use a single time. I know how to use it for one of them,

<xs:element name="BAR1">
   <xs:simpleType>
       <!-- my type definition here -->
   </xs:simpleType>
</xs:element>

But I want to use it in two (and maybe more) elements, and I am not sure how I can do this without copying the same simple type definition everywhere. From googling, it seems that I need to declare the type with a name

But I don’t know where to put this declaration. I try to put it in the same level in as xs:complexType and several other level, but it was rejected by the schema validator. Any idea where to put this declaration?
Any idea?

  • 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-13T13:05:17+00:00Added an answer on June 13, 2026 at 1:05 pm

    All referenceable components in an XSD file must be placed directly under the xs:schema element. In other words, your global simple type declarations must be siblings of the FOO element.

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xs:element name="FOO">
            <xs:annotation>
                <xs:documentation>Comment</xs:documentation>
            </xs:annotation>
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="BAR1" type="BAR" />
                    <xs:element name="BAR2" type="BAR" />
                    <xs:element name="BAR3" type="xs:string" />
                    <xs:element name="BAR4" type="xs:string" />
                </xs:sequence>
            </xs:complexType>
        </xs:element>
        <xs:simpleType name="BAR">
            <xs:restriction base="xs:string">
                <xs:pattern value="BAR"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:schema>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I now have a file uploader that goes on like this This is the
I have found that the xmldsig-core-schema.xsd file that I was using in my application
With help from you guys I now have a script that works like a
I have an XML file that is validating against a schema. However on our
Right now we have static code to a XML schema file. But now we
I have a ConfigParameter SLSB that reads configuration values from the ejb-jar.xml file. This
I have an XSD file with an enumerated type. I'd like to create an
In an xsd file I have this element base type : <xs:complexType name=event abstract=true
I have this as a XML file and I'd like to write a serializable
OK, I generated C# classes from my huge XSD file. Now I have a

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.