CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    13

    Limiting attributes of multiple elements with XML Schema

    I am working with a curriculum development group and we are trying to get all of their content into an XML format so that it can be easily displayed by a browser and parsed by our application. For quiz pages we would like to do something like the following:

    Code:
    <question>
      <text>Who won superbowl XXXII?</text>
      <answer correct="false">Green Bay Packers</answer>
      <answer correct="true">Denver Broncos</answer>
      <answer correct="false">Dallas Cowboys</answer>
      <answer correct="false">Atlanta Falcons</answer>
    </question>
    However, I can't find a way to limit it so that only one answer element within a question element can have a correct attribute with the value of true. Is this possible? Also of course it would be preferable to have false be the default value for the attribute so that it wouldn't be necessary for any element other than the correct answer.

    Additionally, if anybody has recommendations for better methods for accomplishing the above goal or already developed XML based languages for curriculum that they have experience with that would be appreciated.

  2. #2
    Join Date
    Oct 2004
    Posts
    107

    Re: Limiting attributes of multiple elements with XML Schema

    I don't believe you can do that in schema. You could restructure it, eg.

    <question>
    <text>Who won superbowl XXXII?</text>
    <correctpos="2"/>
    <answer pos="1">Green Bay Packers</answer>
    <answer pos="2">Denver Broncos</answer>
    <answer pos="3">Dallas Cowboys</answer>
    <answer pos="4">Atlanta Falcons</answer>
    </question>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured