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

alitur juho.rutila at gmail.com
Thu Sep 13 23:21:39 MST 2012


"uckelman" wrote:
> 
> Code:
> 
>   <img>{FRONT}</img>
> 
> 
> 
> My reason for having no contents for img elements is that they're all
> intended to be references to images defined elsewhere.
> 


Yeah, I wasn't 100% sure about this. Can you explain why a piece knows
its image and not the other way round? Because the image itself is not
essential part of the "piece" concept. There could be for example
different tilesets representing pieces. I think that piece should not
reference image at all.


"uckelman" wrote:
> 
> 
> Code:
> 
>   <property type="int" id="movement allowance">4</property>
> 
> 
> 
> How would you validate that the contents of property elements are the
> correct type this way? Ainulindale brought this up over IRC this
> evening.
> 


Huh, did a lot of googling and I think I stepped in a trap here. It
indeed is not possible to give the element type in an attribute. On the
other hand those "stringproperty"-tags also seemed odd to me. How about
this:

Code:

<gamebox xmlns="http://www.vassalengine.org/v4.xsd"
xmlns:bfm="http://www.vassalengine.org/mods/bfm/battleformoscow.xsd">
<piece id="Soviet army" abstract="true">
 <name>abstract</name> <!-- this is common for all pieces -->
 <properties>
  <bfm:movement_allowance>4</bfm:movement_allowance>
 </properties>
</piece>




Now the properties of the piece could be found under the properties tag.
Property name would be the element name. The validation that
movement_allowance should be int could be defined in
battleformoscow.xsd. But is this only leading us to the next step?


Code:

<gamebox xmlns="http://www.vassalengine.org/v4.xsd"
xmlns:bfm="http://www.vassalengine.org/mods/bfm/battleformoscow.xsd">
<pieces>
 <bfm:soviet_army abstract="true">
  <name>abstract</name> <!-- this is common for all pieces -->
  <properties>
   <bfm:movement_allowance>4</bfm:movement_allowance>
  </properties>
 </bfm:soviet_army>
 <bfm:su_1_shock extends="bfm:soviet_army">
  <name>SU 1 Shock</name>
 </bfm:su_1_shock>
</pieces>




That would be even more xml-ish but it splits the definition to two
files (xml and xsd).

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


More information about the messages mailing list