Skip to main content



      Home
Home » Modeling » XSD » Branching Schema(Restricting Elements based on the state of other Elements/Attributes)
Branching Schema [message #783493] Wed, 25 January 2012 15:32
Eclipse UserFriend
I am writing my first XSD, and I am hoping for a little help.

I am adding items to a database that requires a particular XML format. Generally, it looks like this:

<Item>
<Action></Action><!--Add, Update, or Delete-->
<ItemCode></ItemCode>
<ItemID></ItemID>
<Color></Color>
<Size></Size>
<About50OtherElements/>
</Item>

When the text in the Element "Action" is "Add," Nearly all elements are required, but ItemID is not required (as it is assigned by the DB).

If the "Action" is "Update" the "ItemID" is required, and all others are optional.

If the "Action" is "Delete" the "ItemID" is required and no other elements can be used.

Is it possible to write an XSD that validates differently based on a value in the target XML document? Am I better off writing a couple of XSDs and managing the difference with whatever I am going to implement this XSD with?

Can I have two Elements with the same name in the same XSD and indicate how they should be applied somehow?

Please help.
Previous Topic:choice between groups in xsd
Next Topic:xml.ecore
Goto Forum:
  


Current Time: Tue Jul 01 06:15:29 EDT 2025

Powered by FUDForum. Page generated in 1.25221 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top