Solved

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

Posted on 2014-11-03
1
615 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
1 Comment
 

Accepted Solution

by:
bhieb earned 0 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now