I have an XSD file which contains the schema for my XML. The XSD file contains an xs:Enumeration
definition, which allows me to choose between 5 options as a value for one of the nodes.
Now, we want to be able to generate this data through Excel, so that non-technical people can create it.
When I import this XSD file into Excel, i want the xs:enumeration
values to be listed as dropdowns.
How do I get to do that?
Edit: Starting a bounty. To win, I need a working sample code for this :)
Go to the Excel file and click on the developer tab, then go to source. This will add a panel to the right, which will allow you to add your XSD by clicking on “XML Maps” at the bottom right. The XML Maps window will open. Click on “Add” and add your XSD.
Enumerations are a base simple type in the XSD specification containing a list of possible values. Single-valued enumerations are shown as restrictions of the base simple type xs:token , as illustrated below: ? < xs:simpleType name=”GraduationPlanTypeMapType”> . . .
Reference the XSD schema in the XML document using XML schema instance attributes such as either xsi:schemaLocation or xsi:noNamespaceSchemaLocation. Add the XSD schema file to a schema cache and then connect that cache to the DOM document or SAX reader, prior to loading or parsing the XML document.
What Is The Full Form Of XSD? The full form of XSD is XML Schema Definition. XSD is a way to formally describe the structure and elements in an XML (Extensible Markup Language) document. The purpose of XSD is to define the legal building blocks that relate to an XML document.
As xcut says, there is no easy way to do this. But it can be done. What you'll need to do is:
WorkbookAfterXmlImport
event to read your schema with MSXML
for your enums.ListObject
.Validation.InCellDropdown
to your
mapped column range, minus the
heading.I eye-balled this question a few times yesterday, and didn't answer it, partly because there is no quick solution to what you're trying to do.
You are a bit unclear on what exactly you're trying to achieve: exporting enums from Excel as a Schema, or importing enums from a Schema into Excel, or round-trip.
If you are willing to maintain your spreadsheet as a "master" copy then you can do the following:
Well, it's an idea, at least :) Alternatively, you can write VBA code into it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With