Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XSD Conditional Elements

XSD Conditional Elements

Scheduled Pinned Locked Moved XML / XSL
databasexmlhelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Skippums
    wrote on last edited by
    #1

    I am attempting to make a schema where the valid options for a given enumeration are based on the content of another tag. Right now, I am attempting the following: I have an element with name="source", which can contain one of the following enumerated values {"src1", "src2"}. Now, what I want to do is to have another element with name="dependent", such that if tag "source" is set to "src1", the user has options {"opt1", "opt2"} for the "dependent" tag. If tag "source" is set to "src2", I would like the user to be able to set the "dependent" tag to one of {"opt3", "opt4"}. I am presently attempting the following:

    xs:choice
    xs:sequence
    <xs:element name="source">
    xs:simpleType
    <xs:restriction base="xs:string">
    <xs:enumeration value="src1"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="dependent">
    xs:simpleType
    <xs:restriction base="xs:string">
    <xs:enumeration value="opt1"/>
    <xs:enumeration value="opt2"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    xs:sequence
    <xs:element name="source">
    xs:simpleType
    <xs:restriction base="xs:string">
    <xs:enumeration value="src2"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    <xs:element name="dependent">
    xs:simpleType
    <xs:restriction base="xs:string">
    <xs:enumeration value="opt3"/>
    <xs:enumeration value="opt4"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:choice>

    However, I am getting the error, "Elements with the same name and in the same scope must have the same type." Is there a way to accomplish what I am trying to do without forcing the tags in either option to have unique names? Thanks,

    Sounds like somebody's got a case of the Mondays -Jeff

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups