There are some confusing aspects to your XML, and some practices that you may end up appreciating.....
Technical
Your XML is valid, but it does not follow best practices. The XML:
<con gurd="min>b" type="if">
This should be written:
<con gurd="min>b" type="if">
Even though your XML is valid, the >
in the attribute value can lead to confusion. Even the XML Syntax parser here on Stack Exchange is failing to parse that part right....
Naming
XML is by nature relatively verbose. You are already 'paying' for that, so you may as well use it to your advantage. con
should be condition
, ins
should be ..... instruction
? What is gurd
?
Additionally, you should be consistent in cases. InOut
should be inputoutput
or something. Mixing cases for XML tag names is a problem. I recommend making it all lowercase. I would actually call it 'interface', and have 'input' and 'output' as child elements.
Functional
When you use XML, you need a parser. There is always a balance between what you parse, and what you let the parser parse. The 'text' component in the XML elements are technically called PCDATA
(Parsed Character Data). The XML Parser will Parse that data looking for more XML. That's all it does. Your actual data has things like: min=a
Is your application manually parsing that content as well? If it is, you should probably make your text content attribute values instead.
Additionally, the white-space in your element text is scattered all over the place. Consider:
<calc>
<ins> a=3 </ins>
<ins> b=5 </ins>
<ins> min=a </ins>
</calc>
<con gurd="min>b" type="if">
<calc>
<ins>min=b</ins>
</calc>
</con>
In your first <ins>
elements you have space surrounding the text. In your later <ins>
there is no space.
Is the space important? If it is, you should either use attributes, or set xml:space="preserve"
on your XML.
Update
FYI, I ran your XML through xmllint and it output your XML as:
<?xml version="1.0"?>
<start>
<InOut>
<in> a </in>
<in> b </in>
<out> min </out>
</InOut>
<calc>
<ins> a=3 </ins>
<ins> b=5 </ins>
<ins> min=a </ins>
</calc>
<con gurd="min>b" type="if">
<calc>
<ins>min=b</ins>
</calc>
</con>
<con gurd="min>b" type="else">
<calc>
<ins>min=a</ins>
</calc>
</con>
</start>
xmllint --format your.xml
is a fantastic commandline tool that validates and reformats your XML to be consistent. I recommend it to anyone using XML that has access to Linux