XML Design

Consider the following XML which is transmitted from Clients to a Server
<?xml version="1.0" encoding="UTF-8"?>
<td:MediaTerminal xmlns:td="http://www.tbd.com/messages">
  <td:MediaSource>
    <td:KeyWord>lena</td:KeyWord>
    <td:UDP>
      <td:Interface>225.10.10.2</td:Interface>
      <td:Port>1234</td:Port>
      <td:TTL>2</td:TTL>
    <td:UDP>
    <td:TCP>
      <td:Interface>225.10.10.2</td:Interface>
      <td:Port>1234</td:Port>
    <td:TCP>
    <td:File></td:File>
  </td:MediaSource>
  <td:MediaDestination Protocol="udp" Port="1234">
    <td:KeyWord></td:KeyWord>
    <td:Interface></td:Interface>
  </td:MediaDestination>
  <td:MediaDestination Protocol="udp" Port="1234">
    <td:KeyWord></td:KeyWord>
    <td:Interface></td:Interface>
  </td:MediaDestination>
</td:MediaTerminal>

Open in new window


The elements under MediaSource, are all optional.  Secondly, if a clients are only allowed to choose td:UDP, td:TCP or td:File for transmittal to the Server.  IOW:  I could do:

<?xml version="1.0" encoding="UTF-8"?>
<td:MediaTerminal xmlns:td="http://www.tbd.com/messages">
  <td:MediaSource>
    <td:KeyWord>lena</td:KeyWord>
    <td:TCP>
      <td:Interface>225.10.10.2</td:Interface>
      <td:Port>1234</td:Port>
    <td:TCP>
  </td:MediaSource>
   :
   :
</td:MediaTerminal>

Open in new window


or

<?xml version="1.0" encoding="UTF-8"?>
<td:MediaTerminal xmlns:td="http://www.tbd.com/messages">
  <td:MediaSource>
    <td:KeyWord>lena</td:KeyWord>
    <td:File></td:File>
  </td:MediaSource>
   :
   :
</td:MediaTerminal>

Open in new window


or

<?xml version="1.0" encoding="UTF-8"?>
<td:MediaTerminal xmlns:td="http://www.tbd.com/messages">
  <td:MediaSource>
    <td:KeyWord>lena</td:KeyWord>
    <td:UDP>
      <td:Interface>225.10.10.2</td:Interface>
      <td:Port>1234</td:Port>
      <td:TTL>2</td:TTL>
    <td:UDP>
  </td:MediaSource>
   :
   :
</td:MediaTerminal>

Open in new window


Two questions:  
1. How does an end user who'll design a client app for interfacing with my server know that the elements are optional?
2. How do they know td:UDP, td:TCP and td:File are mutually exclusive
3.  How does the approach above compare to the one below  (i.e. what's good practice)?  Think I've perused alot of documentation on XML design but would like a second/third opinion on approach used.

  <td:MediaSource>
    <td:KeyWord>lena</td:KeyWord>
    <td:UDP Interface="225.10.10.1" Port="1245">
      <td:TTL>2</td:TTL>
    <td:UDP>
    <td:TCP Interface="225.10.10.2" Port="33223">
    <td:TCP>
    <td:File>"Test"</td:File>
  </td:MediaSource>

Open in new window

forums_mpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
1. Tell them
2. Tell them
3. Uhmmm - 6 of one and half a dozen the other. In the latter you are sending unneeded data but in the realm of a few bytes it's unlikely to make much difference but since you can only have one or the other it's more likely confusing.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
forums_mpAuthor Commented:
What would your recommendation on eliminating the confusion?
0
GaryCommented:
Only allow a single node for one or the other values - td:UDP, td:TCP or td:File
0
forums_mpAuthor Commented:
Not sure I'm following. Demonstrate with an example using the mediaSource element to show what you're proposing
0
GaryCommented:
You already have the samples in your opening question where you asked which was better
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.