How to represent the following data in XML format?
commandA ( a | b | c )
position = pos [(m | n | o )]
[space = space] [(m|n|o)]
[option1]
[option2 = "Hello"]
[option3]
Note:
[ ] –> denotes optional,
( ) –> denotes mandatory
| –> denotes anyone of the value
Eg:
commandA a position = 1.0<m> space = 2.0<n> option1 option2="Hello"
How to effectively represent this data in xml?
I tried something like this,
<command name="commandA" position = "position" >
<option name="option1"/>
<option name="option2" value = "Hello"/>
<option name="option3"/>
</command>
But how to handle the command value i.e a|b|c and position i.e m|n|o ?
EDIT:
Command: Syntax:
commandA (a|b|c) pos=0[w|x|y|z] [spa=0.0[w|x|y|z]] [str=”Hello”]
commandA a pos=0w spa=0.0z str=”Hello”
I tried something like this,
<command name="commandA">
<direction>
<direction name="a"/>
<direction name="b">
<direction name="c"/>
</direction>
<parameter>
<position value="pos=0" />
<spacing value="spa=0.0" />
<options>
<option name="w"/>
<option name="x"/>
<option name="y"/>
<option name="z"/>
</options>
</parameter>
<string value="str=" />
</command>
Any suggestions on this?
How about something like this. It combines tags to guide the autocompletion, along with tags for the command DOM:
The autocompletion code matches literal element text exactly once, unless it is contained in a
choiceoroptionaltag, which changes the behavior accordingly. I’ve put these autocomplete tags in a separate namespace, to separate what the auto-complete code recognises, and what is the DOM, although you don’t have to maintain a separate namespace if you don’t want to.The
matchtag matches/completes text according to a regular expression. When building the DOM, the match tags are replaced with the literal text that was entered.The auto-complete tags tell the auto-completion how to deal with child tags. The names of the child tags are arbitrary and are not used by auto-completion, but can be used in building a DOM for your command that the user has typed in: once the auto-complete has built the model, and auto-complete tags removed, what remains is a DOM for the command the user typed in.