P
Philipp
Hello. OK I know this is the most asked question in XML (it says in some
tutorial), but still. Please give me your insight on this (as I'm a newbie).
I want to store parameters for a programm in an XML file. I can see 3
intelligent ways to this.
1)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<LPAR name="Coverage" unit="ML">0.1</LPAR>
<LPAR name="Frequency" unit="Hz">10^3</LPAR>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
2)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<Coverage unit="ML">0.1</Coverage>
<Frequency unit="Hz">10^3</Frequency>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
3)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<LPAR name="Coverage" unit="ML" value="0.1"\>
<LPAR name="Frequency" unit="Hz" value="10^3"\>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
As far as I see, all three are valid
- no multiple attributes with same name
- the "value" is atomic, so can be stored in an attribute
- I cannot think of any parameter (Coverage/Freq) which should need to
be extensible later on.
But
- one attribute (unit) modifies another (value) in version (3), which
seems to be bad practice
- I would like to address the parameters directly (using tinyXML), so
it's easier (is-it?) in version 2 where the Element name, reflects the
purpose. So you can write something like
(pseudocode)
doc.getElement("Coverage")
and not
if(doc.getElement("LPAR").getAttribute("name") == "Coverage"){...}
What do you think? Any good advice on which is better?
Thanks Philipp
tutorial), but still. Please give me your insight on this (as I'm a newbie).
I want to store parameters for a programm in an XML file. I can see 3
intelligent ways to this.
1)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<LPAR name="Coverage" unit="ML">0.1</LPAR>
<LPAR name="Frequency" unit="Hz">10^3</LPAR>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
2)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<Coverage unit="ML">0.1</Coverage>
<Frequency unit="Hz">10^3</Frequency>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
3)
<?xml version="1.0" ?>
<PARAMETERS>
<LATTICE>
<LPAR name="Coverage" unit="ML" value="0.1"\>
<LPAR name="Frequency" unit="Hz" value="10^3"\>
</LATTICE>
... (other params in other elements)
</PARAMETERS>
As far as I see, all three are valid
- no multiple attributes with same name
- the "value" is atomic, so can be stored in an attribute
- I cannot think of any parameter (Coverage/Freq) which should need to
be extensible later on.
But
- one attribute (unit) modifies another (value) in version (3), which
seems to be bad practice
- I would like to address the parameters directly (using tinyXML), so
it's easier (is-it?) in version 2 where the Element name, reflects the
purpose. So you can write something like
(pseudocode)
doc.getElement("Coverage")
and not
if(doc.getElement("LPAR").getAttribute("name") == "Coverage"){...}
What do you think? Any good advice on which is better?
Thanks Philipp