Storing general-purpose and specific entries

R

Robert Bj?rn

I would like to store a number of entries in XML format. For this I
require attributes that describe information common to all entries, as
well as additional information that depends on the type of entry.

What is the best way of solving this in XML, while not contradicting
the standard and ensuring maximum flexibility? I can think of a few
different approaches:

1) Define elements with different names for each type of entry,
something like this:

<greenentry name="something" size="3" greensetting1="x"
greensetting2="y">
<redentry name="something" size="3" redsetting1="x" redsetting2="y">

The problem obviously is that each of the elements would have to
include, in the specification, those attributes (in the case above,
"name" and "size") common to all entries. That doesn't seem ideal.

2) Another solution I can think of, would be to nest specific
information inside a general element, like this:

<entry name="something" size="3">
<greenentry greensetting1="x" greensetting2="y" />
</entry>
<entry name="something" size="3">
<redentry redsetting1="x" redsetting2="y" />
</entry>

None of these approaches seem ideal to me. I would appreciate hearing
any suggestions or recommendations. Have I missed some solution? How
would you do it?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top