Wednesday, January 28, 2009

XML Schema for Charting - a first implementation


<?xml version="1.0"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="LineChart" type="line_chart"/>

<xs:complexType name="line_chart">
<xs:all>
<xs:element name="LineChartInfo" type="chart_info" />
<xs:element name="Points" type="points_" />
</xs:all>
</xs:complexType>

<xs:complexType name="chart_info">
<xs:all>
<xs:element name="ChartHead" type="xs:string"/>
<xs:element name="width" type="chart_measure"/>
<xs:element name="height" type="chart_measure"/>
<xs:element name="xSpace" type="xs:integer"/>
</xs:all>
</xs:complexType>

<xs:complexType name="points_">
<xs:sequence>
<xs:element name="Point" type="point_" minOccurs="2" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="point_">
<xs:all>
<xs:element name="Label" type="xs:string"/>
<xs:element name="Action" type="xs:string"/> <!-- ENUM -->
<xs:element name="x" type="xs:integer"/>
<xs:element name="y" type="xs:decimal"/>
</xs:all>
</xs:complexType>

<xs:simpleType name="chart_measure">
<xs:restriction base="xs:integer">
<xs:minInclusive value="100"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>


This is just a start, my idea is to first provide information about the chart (a line chart in this test), that should be useful to the xml stylesheet transformation (for example: width and height to set in the svg, head to titled the chart, xspace tell us how much pixel separate every x point).
Then every Point element set x, y for each point and its label.
Soon a new version and the xsl to test it =). And then of course more extensive explanation on this and the older post.
So.. stay tune again !