Re: [xsl] is there any XSL Splitter to split XML in 200 chunk of record

Subject: Re: [xsl] is there any XSL Splitter to split XML in 200 chunk of record
From: "Peter Flynn peter@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 12 Jul 2017 19:19:41 -0000
On 07/12/2017 10:52 AM, Martin Honnen martin.honnen@xxxxxx wrote:
> Do you want to create several result files, each containing a certain
> number of records? Or simply one file where you wrap a certain number of
> records?

I think he means the latter, grouping 200 <name> elements at a time and
(in effect) splitting the <optical> container between the 200th and
201st <name> element, between the 400th and 401st, etc. The result tree
would then be serialised inside a new <opticals> root element.

///Peter

> 
> 
> In any way, assuming XSLT 2.0, you can use positional grouping e.g.
> 
> 
> <xsl:for-each-group select="/optical/name" group-by="(position() - 1)
> idiv 200">
> 
>    <xsl:result-document select="result{position()}.xml">
> 
>     <optical>
> 
>      <xsl:copy-of select="current-group()"/>
> 
>   </optical>
> 
>   </xsl:result-document>
> 
> </xsl:for-each-group>
> 
> 
> Am 12.07.2017 um 11:11 schrieb Rahul Singh rahulsinghindia15@xxxxxxxxx:
>> Hi,
>>
>> Is there any posiblites in XSL to split XML in 200  200 chunk of
>> record in same xml by xsl, *below is inputm expected putput, xsl:*
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <optical>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>> </optical>
>>
>> *Expected output:*
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <opticals>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>> </optical>
>> <optical>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>>   <name>
>>     <Doc>log00.txt</Doc>
>>   </name>
>> </optical>
>> </opticals>
>> *
>> *
>> *XSL:*
>> *
>> *
>> *
>> <xsl:stylesheet version="2.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>>     <xsl:output omit-xml-declaration="yes" indent="yes"/>
>>     <xsl:template match="optical">
>>         <xsl:for-each select="name/Doc">
>>             <xsl:copy-of select="."/>
>>                 <xsl:if test="not(position() eq last())">
>>                 </xsl:if>
>>         </xsl:for-each>
>>     </xsl:template>
>> </xsl:stylesheet>
>>
>> *
>>
>> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
>> EasyUnsubscribe <-list/582271> (by email)
> 
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <-list/2554186>
> (by email <>)

Current Thread