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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:32:22+00:00 2026-06-14T10:32:22+00:00

i have an xml input like below and wanted to create an XML schema

  • 0

i have an xml input like below and wanted to create an XML schema for it.But the schema that i created seems like having problem.Is it possible to show me how to create the schema for the xml below.

-ownerName in ownerDetail element references to farmOwnerName in farm element

<Country>
  <state>
     <farm farmOwnerName="Jerry" produce="apple">
       <established>1974</established>
       <totalWorker>30</totalWorker>
     </farm>
     <farm farmOwnerName="Ronald" produce="apple" quality="best">
       <established>1969</established>
       <totalWorker>15</totalWorker>
     </farm>
     <farm farmOwnerName="Richard" produce="lemon">
       <established>1970</established>
       <totalWorker>20</totalWorker>
     </farm>
  </state>
  <ownerDetail age="70" ownerName="Ronald">
     <bornIn>Australia</bornIn>
  </ownerDetail>
  <ownerDetail age="50" ownerName="Richard">
     <bornIn>Canada</bornIn>
  </ownerDetail>
</Country>

The schema i that i coded is below:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
<xs:element name="state" type="xs:string"/>
<xs:element name="established" type="xs:integer"/>
<xs:element name="totalWorker" type="xs:integer"/>
<xs:element name="bornIn" type="xs:string"/>

<xs:element name="Country">

<xs:complexType name="farm">
    <xs:sequence maxOccurs="unbounded">
        <xs:element ref="established"/>
        <xs:element ref="totalWorker"/>
    </xs:sequence>
    <xs:attribute name="farmOwnerName"  use="required"/>
    <xs:attribute name="produce"  use="required"/>
    <xs:attribute name="quality"  use="optional">
        <xs:simpleType>
            <xs:restriction base="xs:token">
                <xs:enumeration value="best"/>
                <xs:enumeration value="normal"/>
                <xs:enumeration value="low"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:attribute>
</xs:complexType>

<xs:complexType name="ownerDetail">
  <xs:sequence maxOccurs="unbounded">
      <xs:element ref="bornIn"/>
  </xs:sequence>
  <xs:attribute name="age" use="required"/>
      <xs:attribute name="ownerName" use="required"/>
</xs:complexType>

  • 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-14T10:32:24+00:00Added an answer on June 14, 2026 at 10:32 am

    Your XML Schema for the give xml should be as follows

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" >
      <xs:element name="Country">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="state">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="farm" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                      <xs:sequence>
                        <xs:element type="xs:short" name="established"/>
                        <xs:element type="xs:byte" name="totalWorker"/>
                      </xs:sequence>
                      <xs:attribute type="xs:string" name="farmOwnerName" use="optional"/>
                      <xs:attribute type="xs:string" name="produce" use="optional"/>
                      <xs:attribute type="xs:string" name="quality" use="optional"/>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
            <xs:element name="ownerDetail" maxOccurs="unbounded" minOccurs="0">
              <xs:complexType>
                <xs:sequence>
                  <xs:element type="xs:string" name="bornIn"/>
                </xs:sequence>
                <xs:attribute type="xs:byte" name="age" use="optional"/>
                <xs:attribute type="xs:string" name="ownerName" use="optional"/>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a xml as below that I'd like to copy n times while
I have a xml as below that I'd like to copy n times while
I have a XML that looks like this (arbitrary XML input) <NodeLevel1> <NodeLevel2> <NodeLevel3>
i have a xml input like below: <food> <fruit>Orange</fruit> isGood <fruit>Kiwi</fruit> isGood <fruit>Durian</fruit> isBad
I have this use case of an xml file with input like Input: <abc
I have written xml file which contains html tags as element like <component> <input
I have an XML like below: <TRANSFORMATION DESCRIPTION = NAME =RTR_LRC_RF_REFL_Unproc OBJECTVERSION =1 REUSABLE
I have a input XML like this : <in_xml> <company> <project> ProjNo1 ProjNo2 ProjNo3
Here is my requirement. My sample input document is like below. (I have added
I have an input xml as below <maindocument> <first> <testing>random text</testing> <checking>random test</checking> </first>

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.