Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert xs:Enumerations in XSD to dropdown lists in Excel

Tags:

xml

excel

xsd

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 :)

like image 745
ashwnacharya Avatar asked Feb 23 '10 18:02

ashwnacharya


People also ask

How do I import an XSD file into Excel?

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.

What is enumeration value in 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”> . . .

HOW include XSD in XML?

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 XSD full form?

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.


2 Answers

As xcut says, there is no easy way to do this. But it can be done. What you'll need to do is:

  1. Use the WorkbookAfterXmlImport event to read your schema with MSXML for your enums.
  2. Find the mapped column in your data table for the element that has your enums in code. This is usually a ListObject.
  3. Add these enums to a list in Validation.InCellDropdown to your mapped column range, minus the heading.
like image 51
Todd Main Avatar answered Nov 13 '22 08:11

Todd Main


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:

  • Main the enums in Excel (e.g. Column A has a type name and the rows in Column B have the values)
  • Periodically, when you need to, hit "Save as..." XML Spreadsheet
  • Run XSLT on the XML spreadsheet to produce the schema file

Well, it's an idea, at least :) Alternatively, you can write VBA code into it.

like image 30
xcut Avatar answered Nov 13 '22 08:11

xcut