excel namespace import problem

M

martinitram

I have experienced the following strange thing:
Mapping a XML file (with or without data) to an Workbook results in Excel
making the 'missing' xsd. I have exported this xsd to a file and saved it als
myxsd.xsd, by running the following VBAcode:
[reference to Microsoft XML, v5.0 added]

Dim xmap As XmlMap
Dim xml As New DOMDocument

For Each xmap In ActiveWorkbook.XmlMaps
xml.loadXML xmap.Schemas(1).xml
xml.Save "testing123.xsd"
next xmap

Now I wanted to map a new excel workbook to this newly created xsd. To my
surprise Excel was not able to do so, giving the error: "Cannot load the
specified XML of schema source" with the detail description:
"/schema/element[1]/ .... Undeclared XSD element:
'{http://www.w3.org/2001/XMLSchema}schema'."

Ok, let's look into the xsd in detail:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns0="http://www.w3.org/2001/XMLSchema">
<xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>
<xsd:element nillable="true" name="root">
<xsd:complexType>
<xsd:sequence minOccurs="0">
<xsd:element minOccurs="0" ref="ns0:schema"/>
[....]

there it is: the xsd:element with the *reference* to ns0:schema!! Why does
Excel not recognize this element all of a sudden? Is it because Excel cannot
map a schema with a imported namespace?? It's a mistery...

--
Martin Drenth
Microsoft Certified Professional
IT architect at Flores Automatisering
Amsterdam, the Netherlands
http://www.flores.nl
 

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