Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Schema design decision

Tags:

xml

xsd

I am designing an XML schema to hold the output of my program. However, I am hesitating concerning a design decision, and I would like the input of more experienced programmers.

If I have a complex element

<list>
<elmt>1</elmt>
<elmt>2</elmt>
</list>

However, the nested elements in <list> are optional. My question is how should the file look like when no <elmt> exist?

Option 1:
<list/> or <list></list>

Option 2: <list size="0" />

Option 3: Remove the element <list> altogether.

I know that these 3 options may not have any difference, but does someone have any preference for some reason (I care more about faster reading of the XML file and easier programming than size)?

like image 258
H-H Avatar asked Feb 20 '26 16:02

H-H


1 Answers

Definitely not option 2. I would prefer option 1 as programmer (the less flexible the schema is, the easier is parsing it) and option 3 as human being writing or reading the XML (fewer characters to type, less clutter). It depends on who is more important for you.

like image 159
Tim Jansen Avatar answered Feb 23 '26 06:02

Tim Jansen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!