Respect Sir/Madam,
Objective : To split Huge input files into smaller files . Each splitted
small file should contain as many number of records from big file as many
as I configure somewhere in smooksConfig file, and not only one record in
each file.
Sample Input :
<?xml version="1.0"?>
<catalog>
<library>
<book1 id="lib-bk1">
<name>headername</name>
<title>headertitle</title>
</book1>
</library>
<book id="bk101">
<author>c</author>
<title>d</title>
</book>
<book id="bk102">
<author>e</author>
<title>f</title>
</book>
<book id="bk103">
<author>g</author>
<title>h</title>
</book>
<book id="bk104">
<author>i</author>
<title>j</title>
</book>
<book id="bk105">
<author>k</author>
<title>l</title>
</book>
<book id="bk106">
<author>c</author>
<title>d</title>
</book>
<book id="bk107">
<author>e</author>
<title>f</title>
</book>
<book id="bk108">
<author>g</author>
<title>h</title>
</book>
<book id="bk109">
<author>i</author>
<title>j</title>
</book>
<book id="bk110">
<author>k</author>
<title>l</title>
</book>
</catalog>
Current output :
It is splitting 10 book records into 10 different files, each containing
one record only.
Current content of each splitted file is similar to below :
With each file containing only one record :
<catalog>
<library>
<book id="lib-bk1">
<name>headername</name>
<title>headertitle</title>
</book>
</library>
<book id="bk101">
<author>c</author>
<title>d</title>
</book>
</catalog>
Expected output for sample:
File should be splitted into four files only, with first three files
consisting of 3 records each and last(fourth) file should consist of last
record.
Please find what I tried below attached.,
Proxy file :"SmooksSample2.xml"
and
SmooksConfig file :"smooks-key2.xml"
With Regards,
Aditya
Mob : +91-8380080226
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:jb="http://www.milyn.org/xsd/smooks/javabean-1.2.xsd" xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.3.xsd" xmlns:file="http://www.milyn.org/xsd/smooks/file-routing-1.1.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="stream.filter.type">SAX</param>
<param name="stream.filter.readerPoolSize">5</param>
</params>
<core:filterSettings type="SAX"/>
<!-- Extract and decode data from the message. Used in the freemarker template (below).
Note that we could also use a NodeModel here... -->
<jb:bean beanId="catalog" class="java.util.Hashtable" createOnElement="catalog">
<jb:value data="catalog/library/book1/@id" property="catalogId"/>
<jb:value data="catalog/library/book1/name" property="headername"/>
<jb:value data="catalog/library/book1/title" property="headertitle"/>
</jb:bean>
<jb:bean beanId="book" class="java.util.Hashtable" createOnElement="book">
<jb:value data="catalog/book/@id" property="bookId"/>
<jb:value data="catalog/book/author" property="author"/>
<jb:value data="catalog/book/title" property="title"/>
</jb:bean>
<ftl:freemarker applyOnElement="book">
<ftl:template>
<!--<catalog>
<library>
<book id="${catalog.catalogId}">
<name>${catalog.headername}</name>
<title>${catalog.headertitle}</title>
</book>
</library>
<book id="${book.bookId}">
<author>${book.author}</author>
<title>${book.title}</title>
</book>
</catalog>-->
</ftl:template>
<ftl:use>
<!-- Output the templating result to the "orderItemSplitStream" file output stream... -->
<ftl:outputTo outputStreamResource="catalogItemSplitStream"/>
</ftl:use>
</ftl:freemarker>
<!-- Create/open a file output stream. This is writen to by the freemarker template (above).. -->
<file:outputStream openOnElement="book" resourceName="catalogItemSplitStream">
<file:fileNamePattern>catalog-${catalog.catalogId}-${book.bookId}.xml</file:fileNamePattern>
<file:destinationDirectoryPattern>C:/Flatfile/smooks/output</file:destinationDirectoryPattern>
<file:highWaterMark mark="10000000"/>
</file:outputStream>
</smooks-resource-list>
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="SmooksSample2"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="vfs">
<target>
<inSequence>
<smooks config-key="smooks-key2">
<input type="xml"/>
<output type="xml"/>
</smooks>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
<parameter name="transport.PollInterval">5</parameter>
<parameter name="transport.vfs.FileURI">file:///C:/Flatfile/smooks/in1</parameter>
<parameter name="transport.vfs.ContentType">application/xml</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file:///C:/Flatfile/smooks/fail</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
<parameter name="transport.vfs.FileNamePattern">.*\.xml</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///C:/Flatfile/smooks/original</parameter>
<description/>
</proxy>_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev