[messages] [Developers] Design of property and piece XML for V4

alitur juho.rutila at gmail.com
Thu Sep 13 12:29:07 MST 2012


I have to comment on the xml syntax. It isn't very ... xml-ish. As I
have developed xml consumers before I suggest to get it right from the
get-go. I have combined suggestions from previous posts and my own
points about the xml syntax to following:

Code:

<?xml version="1.0" encoding="UTF-8"?>
<gamebox xmlns="http://www.vassalengine.org/v4.xsd">
  <enum id="side">
   <item>SU</item>
   <item>DE</item>
  </enum>
  <template id="faces">
    <parameter id="FRONT"/>
    <parameter id="BACK"/>
    <parameter id="FULL"/>
    <parameter id="HALF"/>
    <body>
      <face>
        <img>{FRONT}</img>
        <property type="int" id="combat strength"
value>{FULL}</property>
      </face>
      <face>
       <img>{BACK}</img>
       <property type="int" id="combat strength">{HALF}</property>
      </face>
    </body>
  </template>  

  <piece id="Soviet army" abstract="true">
      <property type="int" default="8" id="FULL"/>
      <property type="int" default="4" id="HALF"/>
      <property type="string" id="name"/>
      <property type="enum" ref="side">SU</property>
      <property type="int" id="movement allowance">4</property>
      <use ref="faces">
         <parameter ref="FRONT"><propertyvalue ref="name"/>
front</parameter>
<!-- or maybe better with something like -->
         <parameter ref="BACK">{name} back</parameter>
      </use>
  </piece>
  <piece id="SU 1 Shock" extends="Soviet army">
    <property id="name">SU 1 Shock</property> <!-- This overrides
"Soviet Army" property "name" -->
  </piece>
...




I will list my notes here:

- xml declaration at the top
- Namespace (xmlns) should be defined. It keeps the format in shape and
xml validation is easy.
- Keep values inside elements and metadata (data about data) on
attributes (check the properties in my example)
- Property type should be an attribute. I do not want to write xml
parser that has to find all intproperties, stringproperties,
enumproperties etc. I just want to enumerate over properties.
- When you reference another element in the xml document, use ref="".
Inside a node I thnk {property-id} is sufficient placeholder.




_______________________________________________
Read this topic online here:
http://www.vassalengine.org/forum/viewtopic.php?p=36029#p36029


More information about the messages mailing list