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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:41:44+00:00 2026-06-15T01:41:44+00:00

I have an input XML schema like below and i wanted my schema to

  • 0

I have an input XML schema like below and i wanted my schema to do 2 things as below as i am not sure on how to code the below 2 constraint.

  1. when an element “established” exists, the other element “planToEstablish” must not occured.Vice versa if the element “planToEstablish” exists, the “established” element must not exists.And both of the element may not exist as well.
  2. The Farm element needs to be validated by both of the “farmOwnerName” and the “produce” attribute. Example if farmOwnerName=”Jerry” produce=”apple”, then we cannot allow another farm with the same farmOwnerName=”Jerry” produce=”apple” to be stored. But we can still store other farm element as long as the “produce” or the “farmOwnerName” is different.Example farmOwnerName=”Jerry” produce=”orange” can still be stored.

Below is the input XML file.

<Country>
 <farm farmOwnerName="Jerry" produce="apple">
   <established>1974</established>
   <totalWorker>30</totalWorker>
 </farm>
 <farm farmOwnerName="Ronald" produce="apple">
   <totalWorker>15</totalWorker>
 </farm>
 <farm farmOwnerName="Richard" produce="lemon">
   <planToEstablish>1970</planToEstablish>
   <totalWorker>20</totalWorker>
 </farm>
</Country>

Below is the XML schema code that i have now.

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

<xs:element name="Country">

<xs:complexType name="farm">
<xs:sequence maxOccurs="unbounded">
    <xs:element ref="established" use="optional"/>
    <xs:element ref="planToEstablish" use="optional"/>
    <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:element>
</xs:schema>
  • 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-15T01:41:45+00:00Added an answer on June 15, 2026 at 1:41 am

    You first constraint is achived with a choice:

    <xs:choice minOccurs="0">
        <xs:element ref="established" use="optional"/>
        <xs:element ref="planToEstablish" use="optional"/>
    </xs:choice>
    

    The second constraint is achieved with an xs:unique constraint on the Country element with selector set to “Farm”, and fields @farmOwnerName and @produce.

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

Sidebar

Related Questions

i have an xml input like below and wanted to create an XML schema
I have written xml file which contains html tags as element like <component> <input
I have this use case of an xml file with input like Input: <abc
I have a stored proc that takes an input of xml value like this:
i have input xml as <content> <date> <day>14</day> <month>06</month> <year>2012</year> </date> </content> want it
I have the following input XML: <root age=1> <description>some text</description> <section> <item name=a> <uuid>1</uuid>
This is my input xml. The xml can have maximunm three nodes and minimum
Note, I am not trying to generate the schema for an XML file from
So I have the following method: private int? myIntField [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] public int?
I have a mapping from xml schema(number) to copybook, copybook field is a number

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.