Rank: Member
Joined: 1/4/2014 Posts: 12
|
I've searched the forums and Google but cannot find a solution.
In XMLSpy I have mapped an XML schema to be exported to a MSSQLServer database that has one column for each unique XML element.
The XML files contain some instances where there are duplicate XML elements (which is desired). When exporting from XMLSpy and Importing to the database, only the first instance of these duplicate elements are entered.
I expected to find that a new row would be created for each duplicate element but this is not the case.
How do I resolve this?
Thank you!
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
You should use Altova MapForce instead of XMLSpy for more complex imports. It is very easy to use and gives you a whole freedom to choose how to convert your data.
|
Rank: Member
Joined: 1/4/2014 Posts: 12
|
vlad wrote:You should use Altova MapForce instead of XMLSpy for more complex imports. It is very easy to use and gives you a whole freedom to choose how to convert your data.
I tried to use MapForce but it was even worse - it seems that it cannot do what XMLSpy can do so that's why I'm stuck using it but if you can tell me how to do the import there instead please do.
|
Rank: Newbie
Joined: 10/28/2002 Posts: 1,283 Location: AT
|
Quote:I tried to use MapForce but it was even worse - it seems that it cannot do what XMLSpy can do so that's why I'm stuck using it but if you can tell me how to do the import there instead please do.
The primary goal of Mapforce is data integration and therefore it can do more in this regard than XML Spy.
I assume you are facing the follow situation:
Code:
<root xsi:noNamespaceSchemaLocation="people.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <person> <name>john</name> <age>25</age> <address>under the bridge</address> </person> <person> <name>mike</name> <age>30</age> <address>beverly hills</address> <address>palm beach</address> </person> </root>
and when you export to the "person" table in XML Spy you get:
Code:
person table:
'john', 25, 'under the bridge'
'mike', 30, 'beverly hills'
If your goal is to get three rows into the "person" table
Code:
person table:
'john', 25, 'under the bridge'
'mike', 30, 'beverly hills'
'mike', 30, 'palm beach'
then you would simply have to use the mapping shown in the first screenshot at the bottom of this posting.
NOTE: It is not clear to me why you would want three rows in the table as opposed to two, because as you can clearly see the third row contains redundant data and you will likely have problems if you have any primary or unique keys defined for the "person" table. The proper way to go about the whole situation would be to have a person and an address table as shown in the second screenshot in this posting which would result in the following output:
Code:
person table:
'1', 'john', 25
'2', 'mike', 30
address table:
'1', 'under the bridge'
'2', 'beverly hills'
'2', 'palm beach'
island attached the following image(s):
|