Tuesday, 11 October 2016

XML : Attributes in a schema file

I'm trying to create an XML file from an Excel sheet. The XML file should contain a list of 'Registers' with the form shown below.

    <?xml version="1.0" encoding="UTF-8"?>      <body>        <Register ID="Foo" Value="42.3" DataType="FLOAT32" />        <Register ID="Bar" Value="92.6" DataType="FLOAT32" />      </body>    

I would like the attributes ID and DataType to be fixed but the Value attribute should be assigned the value of a mapped cell in Excel.

So far i have been playing around whith a schema file, but have been unable to assign fixed values to attributes.

  <xs:element name="Register">    <xs:complexType>          <xs:attribute name="ID" type="xs:string" fixed="Foo"/>          <xs:attribute name="DataType" type="xs:string" fixed="FLOAT32"/>      <xs:sequence>          <xs:element name="Value" type="xs:decimal"/>      </xs:sequence>    </xs:complexType>  </xs:element>    </xs:schema>    

Any help on fixing the schema file would be appreciated!

No comments:

Post a Comment