Options for XML files
The XML file must exist.
| File | Select file via “...” |
Please note that the file’s structure must be readable, e. g.:
<measurement>
<temperature>
<ID>1</ID>
<time>2012-01-31T12:00:00</time>
<value>5</value>
</temperature>
<temperature>
<ID>2</ID>
<time>2012-01-31T12:05:00</time>
<value>4</value>
</temperature>
<pressure>
<ID>1</ID>
<time>2012-01-31T12:00:00</time>
<value>1200</value>
</pressure>
<pressure>
<ID>2</ID>
<time>2012-01-31T12:05:00</time>
<value>4</value>
</pressure>
</measurement>
Speaking in database terms, this means, we have got a database measurement containing tables temperature and pressure, each containing columns ID, time and value. Each table in this file has got two records. The XML elements must not contain attributes!
From this file, you will be able to read data. Pleas note that a column ID has to be part of each table.
To write data to an XML file, each table needs a primary key. This can be realized with an XML schema (XSD = XML Schema Definition). This XSD file is referenced in the root element of your XML file. The following example shows the reference to an XSD file stored in the same location as the XML file.
<measurement xmlns="measurement.xsd">
...
</measurement>
The referenced file measurement.xsd contains the definition:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="measurement" targetNamespace="measurement.xsd" xmlns:mstns="measurement.xsd" xmlns="measurement.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="temperature" msprop:Generator_UserTableName="temperature">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="time" msdata:Caption="Zeit" type="xs:dateTime" minOccurs="0" />
<xs:element name="value" msdata:Caption="Wert" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="pressure" msprop:Generator_UserTableName="pressure">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" msdata:ReadOnly="true" msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="time" msdata:Caption="Zeit" type="xs:dateTime" minOccurs="0" />
<xs:element name="value" msdata:Caption="Wert" type="xs:int" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="indexes" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="temperature" />
<xs:element ref="pressure" />
</xs:choice>
</xs:complexType>
<xs:key msdata:PrimaryKey="true" msdata:ConstraintName="temperatureID" name="temperatureID">
<xs:selector xpath=".//temperature" />
<xs:field xpath="ID" />
</xs:key>
<xs:key msdata:PrimaryKey="true" msdata:ConstraintName="pressureID" name="pressureID">
<xs:selector xpath=".//pressure" />
<xs:field xpath="ID" />
</xs:key>
</xs:element>
</xs:schema>
The first two elements define the tables’ layout, the third element the indexes. Relations could be realized as well. Please not that each table has to have at least one record with a valid ID so that the auto increment function works correctly (IDs of new records are set automatically.
Important: In the Router’s plug-in configuration, you specify the XML file, not the schema (XSD). The XSD file is only referenced from the XML file as shown above.