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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:18:48+00:00 2026-05-14T23:18:48+00:00

to make xsd for element with same names that only identifyed by attribute value

  • 0

to make xsd for element with same names that only identifyed by attribute value example :-

<a>
  <b n="structure one">
    <c n="inner element 1"/>
    <c n="inner element 2"/>
    <c n="inner element 3"/>
  </b>
  <b n="structure two">
    <c n="inner element 1 for structure two"/>
    <c n="inner element 2 for structure two"/>
    <c n="inner element 3 for structure two"/>
  </b>
</a>

notice that from the XML i have to mention specific value that belong to the inner element same for structure

  • 1 1 Answer
  • 1 View
  • 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-14T23:18:48+00:00Added an answer on May 14, 2026 at 11:18 pm

    Not sure what your specific requirements are, but the following schema validates your document. It says that the root element must be named a, and it can contain any number of b elements, which themselves contain any number of c elements. The b and c elements must contain the attribute with the name n.

    <xs:schema attributeFormDefault="unqualified" 
               elementFormDefault="qualified" 
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:element name="a">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="b">
              <xs:complexType>
                <xs:sequence>
                  <xs:element maxOccurs="unbounded" name="c">
                    <xs:complexType>
                      <xs:attribute name="n" type="xs:string" use="required" />
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="n" type="xs:string" use="required" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    

    If you want to constrain the attributes to a specific set of values, you can use a restriction. This schema enumerates the possible values of the n attributes on the b and c elements:

    <xs:schema attributeFormDefault="unqualified"
               elementFormDefault="qualified"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <xs:element name="a">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="b" type="b"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
      <xs:complexType name="b">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="c">
            <xs:complexType>
              <xs:attribute name="n" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:enumeration value="inner element 1"/>
                    <xs:enumeration value="inner element 2"/>
                    <xs:enumeration value="inner element 3"/>
                    <xs:enumeration value="inner element 1 for structure two"/>
                    <xs:enumeration value="inner element 2 for structure two"/>
                    <xs:enumeration value="inner element 3 for structure two"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
    
        <xs:attribute name="n" use="required">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="structure one"/>
              <xs:enumeration value="structure two"/>
              <xs:enumeration value="structure three"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:complexType>
    
    </xs:schema>
    

    You can also constrain the values of the attributes with a regex pattern, like this:

    <xs:schema attributeFormDefault="unqualified"
               elementFormDefault="qualified"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <xs:element name="a">
        <xs:complexType>
          <xs:sequence>
            <xs:element maxOccurs="unbounded" name="b" type="b"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
      <xs:complexType name="b">
        <xs:sequence>
          <xs:element maxOccurs="unbounded" name="c">
            <xs:complexType>
              <xs:attribute name="n" use="required">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:pattern value="^inner element [0-9]+.*$"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:attribute>
            </xs:complexType>
          </xs:element>
        </xs:sequence>
    
        <xs:attribute name="n" use="required">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:pattern value="structure (one|two|three)"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:complexType>
    
    </xs:schema>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 433k
  • Answers 433k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand you correctly, this plugin might help. (The… May 15, 2026 at 2:57 pm
  • Editorial Team
    Editorial Team added an answer You should save a reference to SynchronizationContext.Current from the UI… May 15, 2026 at 2:57 pm
  • Editorial Team
    Editorial Team added an answer this should work just fine or at least lead you… May 15, 2026 at 2:57 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.