views:

27

answers:

2

hi, i need to save objects that can occur multiple times. each object is marked with unique identifier. when it is serialized first time all its properties are written. after that only references are used.

<actionHistory>    
  <add>
    <figure id="1" xsi:type="point">
      <position x="1" y="2" />
    </figure>
  </add>
  <change>
    <target ref="1" />
    <property>x</property>
    <value>3</value>
  </change>
</actionHistory>

element 'target' only references to point saved before, but it can contain definition of new figure as well. there is also figure class hierarchy involved.

is there any way to express it using xml-schema? any suggestions how to improve code above will be also appreciated.

A: 

I think these kind of validations can be done using schematron instead of XSD

Laxmikanth Samudrala
A: 

You can use xs:key to specify that "id" must be unique and xs:keyref to express that "ref" is reference to a previously defined "id". See an example here : http://www.xml.com/pub/a/2000/11/29/schemas/part1.html?page=6

FenchKiss Dev