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!

XML structure best practice

Status
Not open for further replies.

SybreG

Programmer
Aug 11, 2010
2
GB
I am writing a program which gets various info from xml files. One of the sections of the xml file is a list of commands which will be executed by the program in order. Each command will have children to provide the data needed for the command so the nodes used will vary depending on the command.
What I'm wondering is whether it is better practice to use this:
Code:
<command enabled='true'>
  <action>MOVE</action>
  <direction>FW</direction>
  <distance>10</distance>
  <speed>3</speed>
</command>
<command enabled='true'>
  <action>ROTATE</action>
  <degrees>-10</degrees>
</command>
or this:
Code:
<command enabled='true'>
  <MOVE>
    <direction>FW</direction>
    <distance>10</distance>
    <speed>3</speed>
  </MOVE>
</command>
<command enabled='true'>
  <ROTATE>
    <degrees>-10</degrees>
  </ROTATE>
</command>

Further info (in case it makes a difference)...
The files will be used in a java/jsp application for editing and python scripts for executing the commands, probably using xml.dom.minidom for the python (ie no xpath processing).
Eventually I will be needing to put the xml files through some kind of verification to make sure the commands have been constructed correctly - ideally this would be through a schema.
 
The second version would be preferrable. Major keywords will be forming the vacabulary of user's specific namespace with the grammar eventually fixed by the schema to construct. With the first version, you would have an extremely hard time constructing the w3c schema. So the choice can be viewed as being pragmatic rather than fighting the unsurmountable obstacle.
 
I thought that would be the case. Thanks for the answer :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top