cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping for 999 split

former_member10771
Active Participant
0 Kudos

Hi All,

I need a sample XSLT mapping as I am doing a split for each 998 line items. The requirement is to create a new document after every 998 line items . So if there are 1000 line items. It will be 998 with one document and 2 with the other document.

Accepted Solutions (0)

Answers (2)

Answers (2)

peter_wallner2
Active Contributor
0 Kudos

Hi Amit,

Try this:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    version="1.0">

<xsl:template match="node()|@*">

        <xsl:copy>

            <xsl:apply-templates select="node()|@*"/>

        </xsl:copy>

    </xsl:template>

   

    <xsl:template match="Position[position() mod 998 = 1]">

        <PositionGroup>

            <xsl:copy-of select=

                ".|following-sibling::Position[not(position() > 997)]"/>

        </PositionGroup>

    </xsl:template>

   

    <xsl:template match="Position"/>

</xsl:stylesheet>

This XSL assumes the records in your XML are called <Position>. It uses the so called identity transform to copy the structure and the second template "counts" and copies your Positions. The 3rd empty template is also necessary, not sure anymore why.

Adapt it to your needs and let me know if it works.

Best regards,

Peter

iaki_vila
Active Contributor
0 Kudos

Hi Amit,

You can do it without XSLT mapping with a Message Mapping, It's better to choose message mapping over XSL mapping. Check this Claus Wallacher 's blog if it is helpful for you

Regards.