Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7827919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:05:48+00:00 2026-06-02T10:05:48+00:00

I have a xml file roughly like this: <batch> <header> <headerStuff /> </header> <contents>

  • 0

I have a xml file roughly like this:

<batch>
    <header>
        <headerStuff />
    </header>
    <contents>
        <timestamp />
        <invoices>
            <invoice>
                <invoiceStuff />
            </invoice>
            <!-- Insert 1000 invoice elements here -->
        </invoices>
    </contents>
</batch>

I would like to split that file to 1000 files with the same headerStuff and only one invoice. Smooks documentation is very proud of the possibilities of transformations, but unfortunately I don’t want to do those.

The only way I’ve figured how to do this is to repeat the whole structure in freemarker. But that feels like repeating the structure unnecessarily. The header has like 30 different tags so there would be lots of work involved also.

What I currently have is this:

<?xml version="1.0" encoding="UTF-8"?>
<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"    
    xmlns:calc="http://www.milyn.org/xsd/smooks/calc-1.1.xsd"
    xmlns:frag="http://www.milyn.org/xsd/smooks/fragment-routing-1.2.xsd"
    xmlns:file="http://www.milyn.org/xsd/smooks/file-routing-1.1.xsd">

    <params>
        <param name="stream.filter.type">SAX</param>
    </params>

    <frag:serialize fragment="INVOICE" bindTo="invoiceBean" />

    <calc:counter countOnElement="INVOICE" beanId="split_calc" start="1" />

    <file:outputStream openOnElement="INVOICE" resourceName="invoiceSplitStream">
        <file:fileNamePattern>invoice-${split_calc}.xml</file:fileNamePattern>
        <file:destinationDirectoryPattern>target/invoices</file:destinationDirectoryPattern>
        <file:highWaterMark mark="10"/>
    </file:outputStream>

    <resource-config selector="INVOICE">
        <resource>org.milyn.routing.io.OutputStreamRouter</resource>
        <param name="beanId">invoiceBean</param>
        <param name="resourceName">invoiceSplitStream</param>
        <param name="visitAfter">true</param>
    </resource-config>

</smooks-resource-list>

That creates files for each invoice tag, but I don’t know how to continue from there to get the header also in the file.

EDIT:

The solution has to use Smooks. We use it in an application as a generic splitter and just create different smooks configuration files for different types of input files.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:05:50+00:00Added an answer on June 2, 2026 at 10:05 am

    I just started with Smooks myself. However… your problem sounds identical to this: http://www.smooks.org/mediawiki/index.php?title=V1.5:Smooks_v1.5_User_Guide#Routing_to_File

    You will have to provide the output FTL format in whole, that’s the downside of using a general purpose tool I guess. Data mapping often includes a lot of what feels like redundancy, one way around this is to leverage convention but that has to be built into the framework.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have xml file with contents like this: <example name={name}/> Is it possible
I have an XML file that starts like this: <Elements name=Entities xmlns=XS-GenerationToolElements> I'll have
I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
I have an xml file like this: <root> <item> <name>one</name> <status>good</status> </item> <item> <name>two</name>
I have XML-file with settings like this <?xml version=1.0 encoding=utf-8 ?> <configuration> <configSections> <sectionGroup
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I have XML file (output of some application) like this: <data> <call function=get_user_data> <output>
I have XML file which looks like this: <?xml version=1.0?> <results> <row id=100><name>name blah</name></row>
I have xml file with TAG like this: <Question>dzia&amp;#322;owa</Question> I'm reading this file using
I have a XML File like that <?xml version=1.0 encoding=utf-8 ?> <Configurations> <EmailConfiguration> <userName>xxxx</userName>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.