[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: is there any XSL Splitter to split XML in 200 chun

Subject: Re: 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
Re:  is there any XSL Splitter to split XML in 200 chun
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.