Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

XML Design

Posted on 2014-07-26
5
Medium Priority
?
134 Views
Last Modified: 2014-08-13
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

0
Comment
Question by:forums_mp
  • 3
  • 2
5 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 300 total points
ID: 40223246
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
 

Author Comment

by:forums_mp
ID: 40223600
What would your recommendation on eliminating the confusion?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40224299
Only allow a single node for one or the other values - td:UDP, td:TCP or td:File
0
 

Author Comment

by:forums_mp
ID: 40229016
Not sure I'm following. Demonstrate with an example using the mediaSource element to show what you're proposing
0
 
LVL 58

Expert Comment

by:Gary
ID: 40229091
You already have the samples in your opening question where you asked which was better
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question