Keep schemaLocation attribute when saving to XML data from Excel

E

Erik Braten

I have an XML file that is related to an XML Schema. Then I open the file in
Excel, edit some data, and save the file as XML Data.
Problem: The resulting XML file is no longer related to the XML Schema.

If I do the same in Word (Office Professional 2003), the schemaLocation
attribute is kept. How can I make sure this happens in Excel (Office
Professional 2003) as well?

Alternative angle:
I don't want to lose the empty elements when saving to an XML file from
Excel. As long as the XML file is related to the schema, these elements are
kept. But if one edits the file a second time, since it is no longer related
to the schema, the empty elements will be lost. Is it perhaps possible to
solve it some other way than through keeping the schema relation?

Simple example of the xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<EquInfo xmlns="http://www.yyy.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.yyy.com exampleSchema.xsd">
<Row rowId="1" >
<Equipment>EquNewType</Equipment>
<Manufacturer></Manufacturer>
<Model></Model>
</Row>
</EquInfo>

The XML Schema:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.yyy.com"
xmlns="http://www.yyy.com"
elementFormDefault="qualified">
<xs:element name="EquInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="Row" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Equipment" type="xs:string"/>
<xs:element name="Manufacturer" type="xs:string"/>
<xs:element name="Model" type="xs:string"/>
</xs:sequence>
<xs:attribute name="rowId" type="xs:positiveInteger"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

Thank you in advance!

best regards,
Erik Braten
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top