1

I'm trying to setup a Schema file for use with Excel XML Mapping. What I want to accomplish is to take each row in my spreadsheet, and have it output XML like this:

Excel Rows:

XML_Name   |    Initiative    |    HitPoints
ad_wasp         5                  42
hob_goblin      7                  22

Desired XML Output:

<entities>
 <ad_wasp>
     <initiative>5</initiative>
     <hitpoints>42</hitpoints>
 </ad_wasp>
 <hob_gob>
     <initiative>7</initiative>
     <hitpoints>22</hitpoints>
 </hob_gob>
</entities>

In other words - I want to make the first row in my Excel sheet a main element tag, and then under that, put the following rows in as sub-elements. I want it in this format as a program I'm working with (Fantasy Grounds 2) accepts modular addons in XML format, and needs uniquely named elements like this, enclosing sub-elements.

Keep in mind - I'm totally new to XML. Maybe I can't do this. What I've been able to pick up in the last 3 hours is ...

  1. In Excel, click into the Developer tab.
  2. Define an XML Map Source
  3. Point it to the XSD

I've created a schema file as you can see below using XMLSpy - BUT, the problem I'm having is that the schema below puts everything in tags like this:

<xml_tag>
    <Name>aasimar</Name>
    <XP>Aasimar</XP>
    <CR>Aasimar</CR>
    <Init>Aasimar</Init>
</xml_tag>

Is there a way to do what I want? If I try to put a "type="xs:string"" declaration into the "XML_Tag" element, I get an error (The 'type' attribute and an anonymous type definition are mutually exclusive for element declaration 'xml_tag'.) However - I don't know how to make the element a "dynamic variable" (probably the wrong jargon to use), as opposed to the same, static tag.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="Entities">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="xml_tag" form="unqualified" nillable="true" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:sequence minOccurs="0">
                            <xs:element name="Name" type="xs:string" form="unqualified" nillable="true" minOccurs="0"/>
                            <xs:element name="XP" type="xs:integer" form="unqualified" nillable="true" minOccurs="0"/>
                            <xs:element name="CR" type="xs:integer" form="unqualified" nillable="true" minOccurs="0"/>
                            <xs:element name="Init" type="xs:integer" form="unqualified" nillable="true" minOccurs="0"/>
                        </xs:sequence>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>
0

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.