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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:40:05+00:00 2026-06-14T09:40:05+00:00

I have gone through many site and then created Xml Schema, where the other

  • 0

I have gone through many site and then created Xml Schema, where the other attributes are depends on the value of one the attributes.

The below xml file:

<?xml version="1.0"?>
<Main>
  <Matter kind="fruits" calories="10" name="apple" quantity="10" color="red"/>
  <Matter kind="car" brand="ford" name="ikon" quantity="1" color="red"/>
  <Matter kind="country" continent="Asia" name="japan"/>
</Main>

The kind attribute can have fruits, car and country. And based on the attribute other parameter are needed, like for country value, the continent attribute required.

And the below is the XSD file,

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="Main">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="Matter"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Matter">
    <xs:complexType>
      <xs:attribute name="name" use="required" type="xs:NCName"/>
      <xs:alt cond="@kind='fruits'"> 
      <xs:attribute name="kind" use="required" type="xs:NCName" fixed="fruits"/>
      <xs:attribute name="color" type="xs:NCName"/>
      <xs:attribute name="quantity" type="xs:integer"/>
      </xs:alt>
      <xs:alt cond="@kind='car'"> 
      <xs:attribute name="kind" use="required" type="xs:NCName" fixed="car"/>
      <xs:attribute name="brand" type="xs:NCName"/>
      <xs:attribute name="quantity" type="xs:integer"/>
      <xs:attribute name="color" type="xs:NCName"/>
      </xs:alt>
      <xs:alt cond="@kind='country'"> 
      <xs:attribute name="kind" use="required" type="xs:NCName" fixed="country"/>
      <xs:attribute name="continent" type="xs:NCName" use="required"/>
      </xs:alt>
    </xs:complexType>
  </xs:element>
</xs:schema>

When I am validating the XML file with the above XSD, I am getting the error that “Element alt is invalid, misplaced, or occurs too often.

Please help me to validate the above file, with proper XSD.

  • 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-14T09:40:06+00:00Added an answer on June 14, 2026 at 9:40 am

    I don’t know where you got the idea of xsl:alt from. Perhaps some proprietary extension of XML Schema?

    The XSD 1.1 standard has a facility called conditional type assignment that is a bit like this, with an element called xs:alternative. XSD 1.1 is supported in recent versions of Xerces and Saxon.

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

Sidebar

Related Questions

I have gone through many links on this site and others but I could
I have gone through many questions asked here and on other forums regarding @property
I have gone through many videos and tutorials explaining about how to configure one
I have gone through many posts on SO regarding this issue: Tried everything in
I want to translate text in Indian languages. I have gone through many articles
I have seen many posting this issue in SO. I have gone through those
I am .net beginner. I have gone through many sites before asking here. I
While attempting to build a website, i have gone through many online tutorials. Thanks
I have googled a lot and even gone through many of this website questions
Hi I have gone through many question on SO this too but its not

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.