I'm working on a custom XML format that involves a formatted list of points. We would like to support multiple types of coordinates systems, such as Cartesian and Spherical. Can this be done?
Example:
<point type="cartesian">
<c1>5.0</c1>
<c2>5.6</c2>
<c3>9.1</c3>
</point>
<point type="spherical">
<c1>5.0</c1>
<c2>5.6</c2>
<c3>9.1</c3>
</point>
Where there are automatically bounds for the spherical coordinates keeping c1 positive, and c2,c3 in the range 0 to 2PI. While having no bounds for c1 through c3 in the cartesian version. If this can not be written as a Scheme, can I at least do it this way?
<point type="cartesian">
<c1 type="cartesian">5.0</c1>
<c2 type="cartesian">5.6</c2>
<c3 type="cartesian">9.1</c3>
</point>
<point type="spherical">
<c1 type="spherical">5.0</c1>
<c2 type="spherical">5.6</c2>
<c3 type="spherical">9.1</c3>
</point>
In this case I know I can enforce constraints on an element by it's type, but can I enforce a particular element to have the same type as it's parent?
I hope this is clear enough to get what I am trying to do here. I want to constrain the type of data the c1 through c3 types will accept by setting the type of the point element.