Solved

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

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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

737 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