Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To make mandatory or not - what's the standard?

Status
Not open for further replies.

mistermr

Programmer
Jan 28, 2010
2
GB
Hi

I'm not sure if this is the correct place to post this question, but I thought I'd give it a go ...

I'm designing an XML schema definition for a data container I'd like to use to pass around from system to system.

Inside the structure I have an optional key/value pair structure which could be populated with some additional information.

This is in the form of:

/additionalInfo/info/key
/additionalInfo/info/value

My question is, as this is an optional element, should the who additionalInfo element be optional or just the info part?

I realise you can do both, and probably both are fine. But as a general rule/standard, which one is better?

One programmer I have asked here has said the following:

"The logic goes along the lines that additionalInfo is a holder, and if there's no actual info in the holder then there's no info, but the holder's always there in case a later part of the message flow adds some."

Although plausible, this doesn't sound right to me?

Thanks in advance

 
There shouldn't have rule/standard imposed on an authoring decision to make on this structure, if I understand properly the description reading between the lines.

There is only a convenience issue if you use w3c schema language.

The problem is that if you do not make info optional (minOccurs="0") the info element would be very difficult to author as now you need to impose a co-occurence constraint on the key and value elements.

Hence, you should make info "optional" and key and value pair to have the default facet: minOccurs="1" and maxOccurs="1" in a sequence.

As long as info element being optional, whether additonalInfo be optional or not does not matter, it is up to the author of the schema.
 
Hi, thanks for your reply.

I am the author of the schema so am wondering whether I should make additionalInfo mandatory or optional.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top