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 8975833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:58:48+00:00 2026-06-15T18:58:48+00:00

My first post here. I have searched but haven’t found what I’m looking for.

  • 0

My first post here. I have searched but haven’t found what I’m looking for.

I am not really sure what technique I need to do the following.

I use Mule 3.3 CE and I need to split XML files. I need to keep the “rootElement” and its attributes in each and every splitted XML. All XML-files will be dropped in the same JMS Queue.

I know how to split the three Product-nodes but how can I keep the “rootElement” on each an every XML-file?

XPath? XSLT? DOM and remove and add nodes?
I would prefer just an XPath but does it have the strength to do this?

<?xml version="1.0" encoding="ISO-8859-1"?>
<rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
           preOrderTo="2012-12-31T23:59:59"
           currency="GBP"
           timeStamp="2012-08-15T23:59:59">
  <Product
             itemID="09999-3-"
             name="Plate"
             description="Plate of blue man"
             tax="0.00"
             eanCode="1234567890123"
             eanType="EAN 13"/>
  <priceBracket quantity="1"
            price="10.98"
            grossPrice="13.00"/>
  <Product
             itemID="12345-3-"
             name="Plate"
             description="Plate of black man"
             tax="0.00"
             eanCode="1234569870123"
             eanType="EAN 13"/>
  <priceBracket quantity="1"
            price="15.98"
            grossPrice="18.00"/>
  <Product
             itemID="98765-3-"
             name="Plate"
             description="Plate of yellow man"
             tax="0.00"
             eanCode="7894567890123"
             eanType="EAN 13"/>
  <priceBracket quantity="1"
            price="20.98"
            grossPrice="24.00"/>
</rootElement>

What I need in Mule 3.3 CE is the following split:

1.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
           preOrderTo="2012-12-31T23:59:59"
           currency="GBP"
           timeStamp="2012-08-15T23:59:59">
<Product
             itemID="09999-3-"
             name="Plate"
             description="Plate of blue man"
             tax="0.00"
             eanCode="1234567890123"
             eanType="EAN 13"/>
<priceBracket quantity="1"
            price="10.98"
            grossPrice="13.00"/>
</rootElement>

2.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
           preOrderTo="2012-12-31T23:59:59"
           currency="GBP"
           timeStamp="2012-08-15T23:59:59">
  <Product
             itemID="12345-3-"
             name="Plate"
             description="Plate of black man"
             tax="0.00"
             eanCode="1234569870123"
             eanType="EAN 13"/>
  <priceBracket quantity="1"
            price="15.98"
            grossPrice="18.00"/>
</rootElement>

3.

<?xml version="1.0" encoding="ISO-8859-1"?>
<rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
           preOrderTo="2012-12-31T23:59:59"
           currency="GBP"
           timeStamp="2012-08-15T23:59:59">
  <Product
             itemID="98765-3-"
             name="Plate"
             description="Plate of yellow man"
             tax="0.00"
             eanCode="7894567890123"
             eanType="EAN 13"/>
  <priceBracket quantity="1"
            price="20.98"
            grossPrice="24.00"/>
</rootElement>
  • 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-15T18:58:49+00:00Added an answer on June 15, 2026 at 6:58 pm

    If you can use XSLT 2.0, here’s one way…

    XML Input

    <rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
        preOrderTo="2012-12-31T23:59:59"
        currency="GBP"
        timeStamp="2012-08-15T23:59:59">
        <Product
            itemID="09999-3-"
            name="Plate"
            description="Plate of blue man"
            tax="0.00"
            eanCode="1234567890123"
            eanType="EAN 13"/>
        <priceBracket quantity="1"
            price="10.98"
            grossPrice="13.00"/>
        <Product
            itemID="12345-3-"
            name="Plate"
            description="Plate of black man"
            tax="0.00"
            eanCode="1234569870123"
            eanType="EAN 13"/>
        <priceBracket quantity="1"
            price="15.98"
            grossPrice="18.00"/>
        <Product
            itemID="98765-3-"
            name="Plate"
            description="Plate of yellow man"
            tax="0.00"
            eanCode="7894567890123"
            eanType="EAN 13"/>
        <priceBracket quantity="1"
            price="20.98"
            grossPrice="24.00"/>
    </rootElement>
    

    XSLT 2.0

    <xsl:stylesheet version="2.0" 
        xpath-default-namespace="http://Ecommerce.com/schemas/loyalist/3" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output indent="yes"/>
        <xsl:strip-space elements="*"/>
    
        <xsl:template match="@*|node()">
            <xsl:copy>
                <xsl:apply-templates select="@*|node()"/>
            </xsl:copy>
        </xsl:template>
    
        <xsl:template match="/*">
            <xsl:apply-templates select="*"/>
        </xsl:template>
    
        <xsl:template match="Product">
            <xsl:result-document href="{@itemID}.xml">
                <xsl:element name="{/*/name()}" 
                    namespace="http://Ecommerce.com/schemas/loyalist/3">
                    <xsl:copy-of select="/*/@*|.|following-sibling::priceBracket[1]"/>
                </xsl:element>
            </xsl:result-document>
        </xsl:template>
    
    </xsl:stylesheet>
    

    Resulting XML files (name based on itemID of Product, but could be changed easily)…

    09999-3-.xml

    <rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
                 preOrderTo="2012-12-31T23:59:59"
                 currency="GBP"
                 timeStamp="2012-08-15T23:59:59">
       <Product itemID="09999-3-"
                name="Plate"
                description="Plate of blue man"
                tax="0.00"
                eanCode="1234567890123"
                eanType="EAN 13"/>
       <priceBracket quantity="1" price="10.98" grossPrice="13.00"/>
    </rootElement>
    

    12345-3-.xml

    <rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
                 preOrderTo="2012-12-31T23:59:59"
                 currency="GBP"
                 timeStamp="2012-08-15T23:59:59">
       <Product itemID="12345-3-"
                name="Plate"
                description="Plate of black man"
                tax="0.00"
                eanCode="1234569870123"
                eanType="EAN 13"/>
       <priceBracket quantity="1" price="15.98" grossPrice="18.00"/>
    </rootElement>
    

    98765-3-.xml

    <rootElement xmlns="http://Ecommerce.com/schemas/loyalist/3"
                 preOrderTo="2012-12-31T23:59:59"
                 currency="GBP"
                 timeStamp="2012-08-15T23:59:59">
       <Product itemID="98765-3-"
                name="Plate"
                description="Plate of yellow man"
                tax="0.00"
                eanCode="7894567890123"
                eanType="EAN 13"/>
       <priceBracket quantity="1" price="20.98" grossPrice="24.00"/>
    </rootElement>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First post here, I have tried searching but couldn't find what I'm looking for
This is my first post here. I have a problem. I need to take
first post here, I come in peace :) I've searched but can't quite find
Well, this is my first post here and really enjoying the site. I have
First post here but been here 1000 times, really like the contribution from other
I have searched, and this post is closest, but not exactly the same. I
My first post here :) I have a summer job doing a bit of
first thread i post here. I have been searching here for answers and almost
First of I have searched everywhere for an answer and have not come across
Hello all this is my first post here i have been working in an

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.