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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:27:46+00:00 2026-05-20T05:27:46+00:00

Suppose I have the following XML, how should I update my XSD schema (described

  • 0

Suppose I have the following XML, how should I update my XSD schema (described below as well) to prevent it’s validation?

Basically, for question #3, it looks like its a single choice question as there is only one answer in the tag. But then there must be at least one tag inside the tag otherwise there is no other question available to select but the correct one.

<?xml version="1.0" encoding="utf-8" ?>
<quiz>
  <question><!-- single choice question -->
    <text>Question 1</text>
    <answers>
      <answer>Answer 1</answer>
      <answer>Answer 2</answer>
      <answer>Answer 4</answer>
      <correct>
        <answer>Answer 3</answer>
      </correct>
    </answers>
  </question>
  <question><!-- multiple choice question -->
    <text>Question 2</text>
    <answers>
      <answer>Answer 1</answer>
      <answer>Answer 3</answer>
      <correct>
        <answer>Answer 2</answer>
        <answer>Answer 4</answer>
      </correct>
    </answers>
  </question>
  <question><!-- doesn't make sense. help me prevent this validation -->
    <text>Question 3</text>
    <answers>
      <correct>
        <answer>Some answer</answer>
      </correct>
    </answers>
  </question>
  <question><!-- all answers are correct -->
    <text>Question 4</text>
    <answers>
      <correct>
        <answer>Answer 1</answer>
        <answer>Answer 2</answer>
        <answer>Answer 3</answer>
        <answer>Answer 4</answer>
      </correct>
    </answers>
  </question>
</quiz>

Here is the XSD:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="quiz">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" name="question">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="text" type="xs:string" />
              <xs:element name="answers">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs="0" maxOccurs="unbounded" 
                     name="answer" type="xs:string" />
                    <xs:element name="correct" minOccurs="1" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element maxOccurs="unbounded" name="answer"
                           type="xs:string" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
  • 1 1 Answer
  • 2 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-05-20T05:27:47+00:00Added an answer on May 20, 2026 at 5:27 am

    The definition of the answer element (\question\answers\answer), should have minOccurs = 1. You originally had this:

    <xs:element minOccurs="0" maxOccurs="unbounded" name="answer" type="xs:string" />
    

    Change it to this and you’ll get the validation you’re looking for:

    <xs:element minOccurs="1" maxOccurs="unbounded" name="answer" type="xs:string" />
    

    However, if you’re looking to validate that the correct sequence has more than one answer listed when there are no “incorrect” answer elements listed in the answers sequence – you’re out of luck. You cannot do that type of validation using XML schemas.

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

Sidebar

Related Questions

I have the following XSLT question: Suppose I have this XML <items> <item> <type>dog</type>
Suppose I have the following XML (which is the embedding of TEI annotation scheme
Suppose I have the following XML file, and I want to use PowerShell (version
Suppose I have the the following xml: <package xmlns=http://example/namespace> <rating system=au-oflc>PG</rating> ... </package> To
Suppose I have following in my web.xml <filter-mapping> <filter-name>F1</filter-name> <url-pattern>/XYZ/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>F2</filter-name> <url-pattern>/XYZ/abc.do</url-pattern>
Suppose I have a directory structure like the following /a/b/testB.xml /a/c/testC.xml /a/testD.xml and I
Suppose I have the following xml template: <?xml version=1.0 encoding=UTF-8 ?> <myXML> <params> <param
Suppose I have a XML schema and want to support some extensions at several
Suppose I have the following xml, what xsl do I need to transform the
Suppose I have the following XML <building> <phonenumber></phonenumber> <room> <phonenumber></phonenumber> </room> </building> Using building.getElementsByTagName('phonenumber')

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.