IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Import only up to 3 first nodes filtered on a condition Options · View
enrico.esposito
Posted: Thursday, January 19, 2017 8:59:22 AM
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):
mapforce.png

vlad
Posted: Thursday, January 19, 2017 2:32:01 PM
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):
Capture.PNG

enrico.esposito
Posted: Thursday, January 19, 2017 3:55:54 PM
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

K101
Posted: Friday, January 20, 2017 12:57:41 PM
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.
enrico.esposito
Posted: Monday, January 23, 2017 8:29:49 AM
Rank: Newbie

Joined: 1/19/2017
Posts: 3
Location: Milan
Ok, let's switch to XSLT2.

Thanks.
Users browsing this topic
guest

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.