|
Rank: Newbie
Joined: 1/19/2017 Posts: 3 Location: Milan
|
we need a particular trasformation and we want to know if it's possible and how. Please, look at our xsd source format and xsd target format as in the image at the bottom of this message.
Considering that: every <item> can have 1 to many <itemChild>, the two nodes are joined by <identity> <item> is mapped on target <row> in the target we have a <row> for every <item>, but we can mapped only up to 3 <itemChild> for every <row> the first three <itemChild> (for <item>) have to be spread in sequence into nodes taxName_1/2/3 and taxNumber_1/2/3 eventually extra <itemChild> have to be ignored we have to use XSLT 1
Here the source xml file:
Code:<order>
<item> <identity>0</identity> </item> <itemChild> <identity>0</identity> <name>London</name> <number>2005</number> </itemChild> <itemChild> <identity>0</identity> <name>Rome</name> <number>3005</number> </itemChild> <itemChild> <identity>0</identity> <name>Tokyo</name> <number>3005</number> </itemChild> <itemChild> <identity>0</identity> <name>Tokyo</name> <number>8005</number> </itemChild> <item> <identity>1</identity> </item> <itemChild> <identity>1</identity> <name>London</name> <number>7005</number> </itemChild> </order>
Here the desired output xml file
Code:<parent>
<row> <orderId>0</orderId> <taxName_1>London</taxName_1> <taxNumber_1>2005</taxNumber_1> <taxName_2>Rome</taxName_2> <taxNumber_2>3005</taxNumber_2> <taxName_3>Tokyo</taxName_3> <taxNumber_3>3005</taxNumber_3> <!-- ignore from the fourth itemChild --> </row> <row> <orderId>1</orderId> <taxName_1>London</taxName_1> <taxNumber_1>7005</taxNumber_1> </row> </parent> enrico.esposito attached the following image(s):
|
|
Rank: Advanced Member
Joined: 12/13/2005 Posts: 2,856 Location: Mauritius
|
Yes, this is possible. See the screenshot below which produces your result
vlad attached the following image(s):
|
|
Rank: Newbie
Joined: 1/19/2017 Posts: 3 Location: Milan
|
Ok thank you, however we can't use xslt2, we need a solution with xslt1
|
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 558
|
It's not feasible to do grouping with XSLT 1 unless you're extremely knowledgeable about XSLT 1, in which case you can manually code some workarounds. If you need to use grouping and want to use MapForce, you'll need to find a way to use XSLT 2.
Keep in mind that there are plenty of XSLT 2 processors which fill a range of platform requirements, and these include Altova's own RaptorXML Server.
|
|
Rank: Newbie
Joined: 1/19/2017 Posts: 3 Location: Milan
|
Ok, let's switch to XSLT2.
Thanks.
|
|
guest |