• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

XML Data Format

Do you prefer attributes in your XML?

  • Yes: attributes are worth it

    Votes: 7 50.0%
  • No: tags-only is better

    Votes: 7 50.0%

  • Total voters
    14

robject

SOC-14 10K
Admin Award
Marquis
Which do you like, tags only, or attributes?

I find tags-only to be easier to look at in general, but having attributes makes the data more compact. So for large data sets, tag-only gets very leggy.

What do you think?

With Attributes

<traveller name="Standard Disposable Titan Battle Dress" TDIF="1.0" av="120" burden="Disposable" class="Dress" code="StDTBD" cr="3000000" descriptor="Battle" kg="2430" size="Titan" stage="Standard" tl="20" type="Armor">
<protections ca="75" fl="75" in="105" ps="15" ra="75" se="75" so="75" />
<qrebs r="-1" s="1" />
</traveller>

Tags Only

Code:
<traveller>
  <name>Standard Disposable Titan Battle Dress</name>
  <TDIF>1.0</TDIF>
  <av>120</av>
  <burden>Disposable</burden>
  <class>Dress</class>
  <code>StDTBD</code>
  <cr>3000000</cr>
  <descriptor>Battle</descriptor>
  <kg>2430</kg>
  <protections>
    <ca>75</ca>
    <fl>75</fl>
    <in>105</in>
    <ps>15</ps>
    <ra>75</ra>
    <se>75</se>
    <so>75</so>
  </protections>
  <qrebs>
    <r>-1</r>
    <s>1</s>
  </qrebs>
  <size>Titan</size>
  <stage>Standard</stage>
  <tl>20</tl>
  <type>Armor</type>
</traveller>
 
My vote was "tags Only" since that make more sense. But I think the best option is something in between. You can make some of the tags more generic, but use the tags to set options.

Code:
<traveller>
  <name>Standard Disposable Titan Battle Dress</name>
  <TDIF>1.0</TDIF>
  <av>120</av>
  <burden>Disposable</burden>
  <class>Dress</class>
  <code>StDTBD</code>
  <cost units="Cr">3000000</cost>
  <descriptor>Battle</descriptor>
  <mass units="kg">2430</mass>
  <protections>
    <ca>75</ca>
    <fl>75</fl>
    <in>105</in>
    <ps>15</ps>
    <ra>75</ra>
    <se>75</se>
    <so>75</so>
  </protections>
  <qrebs>
    <r>-1</r>
    <s>1</s>
  </qrebs>
  <size units="name">Titan</size>
  <stage>Standard</stage>
  <tl>20</tl>
  <type>Armor</type>
</traveller>
 
The example in post 2 is a good example of the middle ground.
I've had to work with some vile XML which abused attributes (too many of them, poor match between their use and the underlying semantics), but having none can also reduce expressiveness.
 
Didn't vote because there was no option for a mix. Strictly one or the other is just as bad, IMO.

For your specific example, I would make Name be an attribute, but everything else would be tags.

As another example for a System, I would have Name & Position be attributes, but everything else tags. Every system has to have a Name and Position.
 
If you really have to use XML, which is a separate argument, my preference is to use tags to store data and attributes to store metadata.

That argues for a mixed approach such as the example provided by tjoneslo. The way the example expresses the mass of the suit as a number, but encodes the units (kg) in an attribute is exactly the right way to go. Attributes should also be used for internal implementation details, such as an ID used within the application to uniquely identify the item.

Simon Hibbs
 
I also have to deal extensively with XML (thank you US government...) and attributes, when used well, definitely increase both human readability and give you a lot more options.

(I have to deal with a schema that is 22000+ lines of definition. And written by several groups with different ideas. And not actually well documented: a standard that is open to interpretation is not a particularly good standard)
 
Back
Top