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

The Archive Base Latest Questions

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

How can I create an xsd to give me this type of xml structure

  • 0

How can I create an xsd to give me this type of xml structure that can go on infinitely?

<?xml version="1.0" encoding="utf-8" ?>
<SampleXml>
    <Items>
        <Item name="SomeName" type="string">
            This would be the value
        </Item>
        <Item name="SecondName" type="string">
            This is the next string
        </Item>
        <Item name="AnotherName" type="list">
            <Items>
                <Item name="SubName" type="string">
                    A string in a sub list
                </Item>
                <Item name="SubSubName" type="list">
                    <Items>
                        <Item name="HowDoI" type="string">
                            How do I keep this going infinately?
                        </Item>
                    </Items>
                </Item>
            </Items>
        </Item>
    </Items>
</SampleXml>

The only solution I have found has been to just repeat in the xsd as many times as I am willing to copy. Like below.

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="SampleXml">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Items">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element maxOccurs="unbounded" name="Item">
                                <xs:complexType mixed="true">
                                    <xs:sequence minOccurs="0">
                                        <xs:element name="Items">
                                            <xs:complexType>
                                                <xs:sequence>
                                                    <xs:element maxOccurs="unbounded" name="Item">
                                                        <xs:complexType mixed="true">
                                                            <xs:sequence minOccurs="0">
                                                                <xs:element name="Items">
                                                                    <xs:complexType>
                                                                        <xs:sequence>
                                                                            <xs:element name="Item">
                                                                                <xs:complexType>
                                                                                    <xs:simpleContent>
                                                                                        <xs:extension base="xs:string">
                                                                                            <xs:attribute name="name" type="xs:string" use="required" />
                                                                                            <xs:attribute name="type" type="xs:string" use="required" />
                                                                                        </xs:extension>
                                                                                    </xs:simpleContent>
                                                                                </xs:complexType>
                                                                            </xs:element>
                                                                        </xs:sequence>
                                                                    </xs:complexType>
                                                                </xs:element>
                                                            </xs:sequence>
                                                            <xs:attribute name="name" type="xs:string" use="required" />
                                                            <xs:attribute name="type" type="xs:string" use="required" />
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                    <xs:attribute name="name" type="xs:string" use="required" />
                                    <xs:attribute name="type" type="xs:string" use="required" />
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
  • 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:07:32+00:00Added an answer on May 14, 2026 at 11:07 pm

    Use <xs:element ref="bla" /> to recursively refer to the elements.
    A simple example:

    <xs:element name="recursive">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="recursive" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    

    Allows you to write this:

    <recursive>
      <recursive>
        <recursive />
      </recursive>
      <recursive />
      <recursive>
        <recursive>
          <recursive />
        </recursive>
      </recursive>
    </recursive>
    

    Usage of the ‘ref’ attribute also helps greatly in increasing the readability of your XSD. This is how I would write yours:

    <?xml version="1.0" encoding="utf-8"?>
    <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    
      <xs:element name="SampleXml">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="Items" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
      <xs:element name="Items">
        <xs:complexType>
          <xs:sequence>
            <xs:element ref="Item" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    
      <xs:element name="Item">
        <xs:complexType mixed="true">
          <xs:sequence>
            <xs:element ref="Items" minOccurs="0" />
          </xs:sequence>
          <xs:attribute name="name" type="xs:string" use="required" />
          <xs:attribute name="type" type="xs:string" use="required" />
        </xs:complexType>
      </xs:element>
    
    </xs:schema>
    

    Note how use of ‘ref’ even when it’s not strictly necessary (such as when SampleXml refers to Items) makes the XSD less of a nested mess and more readable.

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

Sidebar

Related Questions

I have a snippet of an XML file that looks like: <?xml version=1.0 encoding=utf-16?>
I want to create an XSD which can generate the following XML. <note> <email:to>abc@def.com</email:to>
How do I create an xsd that can validate either of the following two
I would like to create an XSD that defines an attribute which can be
I have a XML schema, and I know that xsd.exe can generate the C#
Tell me please, how can I create xsd schema, which successfully validate the following
I can create a contact that is not mail enabled, but how do I
One can create an anonymous object that is initialized through constructor parameters, such as
In my schema I have some types that simply extend a simple XSD type
I'm currently trying to create an XSD where I have a which can have

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.