Solved

XML export fails Excel 2007 Error: A mapped elements relationship cannot be preserved

Posted on 2014-11-03
1
797 Views
Last Modified: 2014-11-05
A bit new to XML, but I get the gist. Problem is the state of NM has an XSD schema file for a bulk filing some permits, however I cannot seem to use it as a source map to create an export spreadsheet. First I got an error regarding lists of lists, but found that in the XSD there was a command call maxoccure = "unbound" that excel 2007 couldn't handle. It was on elements that we only need 1 anyway so I just hard coded a number instead of unbound.  That part of the verify for export went away, but now i still get the "a mapped element's relationship with other elements cannot be preserved" error.

Getting them to change it is probably not gonna work, so I thought someone here could ID the problem. I've attached the XSD and a sample spreadsheet. The error doesn't happen until I try to add something in the FilerInformation element.
WDTPermit-XML-2.0.xsd
Book1.xlsx
0
Comment
Question by:bhieb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
bhieb earned 0 total points
ID: 40424390
I figured it out sort of.  Excel didn't like the choice element on the PreparerID, either that or it was to many elements deep. I'll just massage the xml export to fit, since I have to anyway to get rid of the ns1: namespace excel is putting in. I know it is doing so because of the schema that the xsd file says too, but the receiver doesn't want it (and they are the ones that miscoded the xsd, gotta love state employees).
<xs:element name="PreparerId">
                                <xs:annotation>
                                    <xs:documentation>Submitted document must contain either PreparerFEIN, PreparerSSN, or PreparerITIN element.</xs:documentation>
                                </xs:annotation>
                                <xs:complexType>
                                    <xs:choice>
                                        <xs:element name="PreparerFEIN">
                                            <xs:annotation>
                                                <xs:documentation>Enter the preparer FEIN. Must be 9 digits.</xs:documentation>
                                            </xs:annotation>
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:pattern value="\d{9}" />
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
                                        <xs:element name="PreparerSSN">
                                            <xs:annotation>
                                                <xs:documentation>Enter the preparer SSN. Must be 9 digits.</xs:documentation>
                                            </xs:annotation>
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:pattern value="\d{9}" />
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
										<xs:element name="PreparerITIN">
                                            <xs:annotation>
                                                <xs:documentation>Enter the preparer ITIN. Must be 9 digits.</xs:documentation>
                                            </xs:annotation>
                                            <xs:simpleType>
                                                <xs:restriction base="xs:string">
                                                    <xs:pattern value="9(\d{8})"  />
                                                </xs:restriction>
                                            </xs:simpleType>
                                        </xs:element>
                                    </xs:choice>
                                </xs:complexType>
                            </xs:element>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question