XML Considerations

0 views
Skip to first unread message

CriticalBotch

unread,
Dec 3, 2009, 10:25:20 PM12/3/09
to CB Development Developer Discussion
I'd like some input on the XML organization. I have a couple of ways
of organizing data. Once is an element centric approach and the other
is an attribute centric approach. Element centric means data is
organized using primarily information between element tags, such as
<element>data</element>

Attribute centric means data is organized primarily with element
attributes, such as <element data="data"/>.

Currently I'm using attributes to as a sort of "formatting
information" - higher level instructions on what to do with the data
found between the element tags. Flags, single item data, etc.

Here's the current set up for classes.xml. I only have one class
defined here for testing purposes.

<classlist>
<class name="Soldier" hitdie="10" skills="3" force="0" base="1">
<defenses>
<defense name="FORT">2</defense>
<defense name="REF">1</defense>
<defense name="WILL">0</defense>
</defenses>
<skills>
<skill>Climb</skill>
<skill>Endurance</skill>
<skill>Initiative</skill>
<skill>Jump</skill>
<skill>Knowledge (tactics)</skill>
<skill>Mechanics</skill>
<skill>Perception</skill>
<skill>Pilot</skill>
<skill>Swim</skill>
<skill>Treat Injury</skill>
<skill>Use Computer</skill>
</skills>
<feats>
<feat start="1">Armor Proficiency (light)</feat>
<feat start="1">Armor Proficiency (medium)</feat>
<feat start="1">Weapon Proficiency (pistols)</feat>
<feat start="1">Weapon Proficiency (rifles)</feat>
<feat start="1">Weapon Proficiency (simple)</feat>
</feats>
<talents>
<talent>Armor Specialist</talent>
<talent>Brawler</talent>
<talent>Commando</talent>
<talent>Weapon Specialist</talent>
</talents>
</class>
</classlist>

The area of gray is the Defenses section. I can list defense values as
I have them with a <defense> element containing a name attribute. I
can also go the route of simply using the name as the element. Instead
of <defense name="FORT">2</defense> I can use <FORT>2</FORT>.

The pros of doing it as I am now are that it's easier to loop through
all the defense elements. I can simply query the tree for all elements
called defense and it'll give me a list containing those three. The
con is that there's more work in getting a specific defense. For
example, if I just wanted the FORT value I'd have to throw in one or
two more processing steps.

The pros of going the other way are that it makes it easy to pull a
single value. I can just query the tree for FORT and immediately have
access to the FORT value. However, getting all the defense values is
harder.

Any thoughts are appreciated.
Reply all
Reply to author
Forward
0 new messages