Really struggling with xsd schema. I have an xml snippet as shown below
<?xml version='1.0' encoding='UTF-8'?>
<testing version="0.1">
<alarms>
<alarm ID="1">
<column name="TYPE">HIGH TEMP</column>
<column name="DISPLAY">High temperature alarm</column>
<column name="VALUE">245.66</column>
</alarm>
<alarm ID="2">
<column name="TYPE">HUMIDITY</column>
<column name="DISPLAY">Humidity alarm</column>
<column name="VALUE">56.44</column>
</alarm>
</alarms>
I have used a few online tools to generate xsd schema for this, however they are not what I was hoping for. The ID column should be mandatory and I don't want to use globals ?.
I also want to place restrictions on the values (i.e validate as decimal) how do I do that
This is what I have so far, I dont know how to validate the columns elements
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="alarms">
<xs:complexType>
<xs:sequence>
<xs:element name="alarm" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="column">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
Regards