Reputation:
I have a Excel worksheet with a list of data, I want to export to XML:
https://i.sstatic.net/GHP7t.jpg
Some have the same IDs, because they have a special relation to each other. I created a xml schema document which looks like this:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="terms">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" minOccurs="0" maxOccurs="unbounded"/>
<xs:element type="xs:string" name="first-name" minOccurs="0" maxOccurs="unbounded" />
<xs:element type="xs:string" name="name" minOccurs="0" maxOccurs="unbounded" />
<xs:element type="xs:string" name="city" minOccurs="0" maxOccurs="unbounded" />
<xs:element type="xs:string" name="gender" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="ID" type="xs:integer" />
</xs:complexType>
</xs:element>
In Excel I want to export my data to a XML file with this schema:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<terms ID="1">
<first-name>Peter</first-name>
<name>xxx</name>
<city>London</city>
<gender>m</gender>
</terms>
<terms ID="1">
<first-name>Lisa</first-name>
<name>xxx</name>
<city>New York</city>
<gender>f</gender>
</terms>
<terms ID="2">
<first-name>Dave</first-name>
<name>xxx</name>
<city>New York</city>
<gender>m</gender>
</terms>
Excel prohibits the export, because the schema is no exportable. How can I export repetetive attributes?
Upvotes: 1
Views: 1085
Reputation:
Found a schema definition to export my data and maybe also interessting for others:
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="terms">
<xs:complexType>
<xs:sequence>
<xs:element ref="entry" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="entry">
<xs:complexType>
<xs:sequence>
<xs:element name="ID">
<xs:complexType />
</xs:element>
<xs:element name="first-name" type="xs:string" />
<xs:element name="name" type="xs:string" />
<xs:element name="city" type="xs:string" />
<xs:element name="gender" type="xs:string" />
</xs:sequence>
<xs:attribute name="ID" />
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 1