Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have found Excel 2013 supports opening, editing and saving XML files. I have created an XML file + XSD which Excel opens without complaints and errors. (I.e. it does not state it has to create schema from the XML data source)

However, Excel still does not respect e.g. restrictions setup in the .XSD file. Is there any way to have Excel do that? (I know Excel is not an XML editor, so I fully accept if it is not possible.)

file data.xsd :

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://example.com" elementFormDefault="qualified">


<xs:element name="data">
<xs:complexType>
<xs:sequence>


<xs:element name="item" minOccurs="0" maxOccurs="unbounded">
  <xs:complexType>
    <xs:all>

      <xs:element name="title" type="xs:string" minOccurs="0" maxOccurs="1">
      </xs:element>

      <xs:element name="type" minOccurs="0" maxOccurs="1">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="header"/>
            <xs:enumeration value="normal"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

      <xs:element name="backgroundcolor" minOccurs="0" maxOccurs="1">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="#[0-9A-Fa-f]+"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>

      <xs:element name="fontcolor" minOccurs="0" maxOccurs="1">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:pattern value="#[0-9A-Fa-f]+"/>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>


    </xs:all>
  </xs:complexType>
</xs:element>


</xs:sequence>
</xs:complexType>
</xs:element>


</xs:schema>

file test.xml :

<?xml version="1.0" encoding="UTF-8"?>
<j:data xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com data.xsd" xmlns:j="http://example.com">

        <j:item>
        <j:title>test title</j:title>
        <j:backgroundcolor>#aaf8941e</j:backgroundcolor>
        <j:fontcolor>#ffffff</j:fontcolor>
        <j:type>header</j:type>
        </j:item>

</j:data>
share|improve this question
    
Hi, can you provide an example XML file? –  nixda Jun 15 '13 at 9:52
    
Hereby added :) –  Tom Jun 15 '13 at 10:02

1 Answer 1

up vote 2 down vote accepted

First of all, there are certain XSD data type attributes that are not supported by Excel. You can see a full list here.

To get Excel to associate your XSD properly with its corresponding XML looks like you'll have to create an XML map and then painstakingly map all the XML elements, as detailed here.

Honestly, I'd advise you to use a proper XML editor and save yourself the headache. :)

share|improve this answer
    
Hi Appreciate your help. Going through it now :) –  Tom Jun 16 '13 at 11:17
    
I have accepted your answer. I will live with the current support in Excel or try tell potential clients they need to use a better (for XML) tool than their favourite. Alternatively I may some day make a web solution for them to enter data into. That will probably make them even happier :) –  Tom Jun 16 '13 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.