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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:43:16+00:00 2026-05-18T00:43:16+00:00

I have an XSLT file so as to transform large amount of data. I

  • 0

I have an XSLT file so as to transform large amount of data. I would like to add a “split” functionality, either as a chained XSLT or within the current XSLT that can create multiple output files so as to limit the size of the files under a certain threshold.
Let’s assume that the input XML is as below:

<People>
<Person>             
<name>John</name>             
<date>June12</date>             
<workTime taskID="1">34</workTime>             
<workTime taskID="2">12</workTime>             
</Person>             
<Person>             
<name>John</name>             
<date>June13</date>             
<workTime taskID="1">21</workTime>             
<workTime taskID="2">11</workTime>             
</Person>
<Person>             
<name>Jack</name>             
<date>June19</date>             
<workTime taskID="1">20</workTime>             
<workTime taskID="2">30</workTime>             
</Person>    
</People>

The XSLT file is as below using muenchian grouping.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="PersonTasks" match="workTime" use="concat(@taskID, ../name)"/>
<xsl:template match="/">
    <People>
    <xsl:apply-templates select="//workTime[generate-id() = generate-id(key('PersonTasks',concat(@taskID, ../name))[1])]"/>
    </People>
</xsl:template>

<xsl:template match="workTime">
    <xsl:variable name="taskID">
        <xsl:value-of select="@taskID"/>
    </xsl:variable>
    <xsl:variable name="name">
        <xsl:value-of select="../name"/>
    </xsl:variable>
    <Person>
        <name>
            <xsl:value-of select="$name"/>
        </name>
        <taskID>
            <xsl:value-of select="$taskID"/>
        </taskID>
        <xsl:for-each select="//workTime[../name = $name][@taskID = $taskID]">
            <workTime>
                <date>
                    <xsl:value-of select="../date"/>
                </date>
                <time>
                    <xsl:value-of select="."/>
                </time>
            </workTime>
        </xsl:for-each>
    </Person>
</xsl:template>
</xsl:stylesheet>

However, I’d like ,as an output, several files as below instead of a large one. For this example, I have set only one name per file..but this should be a parameter.

Output file for first person:

<People>
    <Person>
        <name>John</name>
        <taskID>1</taskID>
        <workTime>
        <date>June12</date>
        <time>34</time>
        </workTime>
        <workTime>
        <date>June13</date>
        <time>21</time>
        </workTime>
    </Person>
    <Person>
        <name>John</name>
        <taskID>2</taskID>
        <workTime>
        <date>June12</date>
        <time>12</time>
        </workTime>
        <workTime>
        <date>June13</date>
        <time>11</time>
        </workTime>
    </Person>
</People>

Output file for second person:

<People>
    <Person>
        <name>Jack</name>
        <taskID>1</taskID>
        <workTime>
        <date>June19</date>
        <time>20</time>
        </workTime>
    </Person>
    <Person>
        <name>Jack</name>
        <taskID>2</taskID>
        <workTime>
        <date>June19</date>
        <time>30</time>
        </workTime>
    </Person>
</People>

What would be the preferred and most elegant approach using XSLT 1.0? Is there a way to call a chained XSLT within the XSLT so as to split the output files?

Cheers.

  • 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-05-18T00:43:17+00:00Added an answer on May 18, 2026 at 12:43 am

    Is there a way to call a chained XSLT
    within the XSLT so as to split the
    output files?

    A few ways:

    1. You could write an extension function to do this — check the documentation of your XSLT processor.

    2. Use the <exsl:document> extension element of EXSLT, in case this is supported by your XSLT processor

    3. Use the <saxon:output> extension element if you have Saxon 6.x

    4. In a loop from your programming language invoke a separate transformation, passing to it as parameter the name of the person for which to produce results.

    Here are code examples for 2. and 3. above:

    Using <saxon:output> :

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:saxon="http://icl.com/saxon"
      extension-element-prefixes="saxon" >
    
     <xsl:template match="/">
      <xsl:for-each select="/*/*[not(. > 3)]">
       <saxon:output href="c:\xml\doc{.}">
        <xsl:copy-of select="."/>
       </saxon:output>
      </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>
    

    when this transformation is applied on the following XML document:

    <nums>
      <num>01</num>
      <num>02</num>
      <num>03</num>
      <num>04</num>
      <num>05</num>
      <num>06</num>
      <num>07</num>
      <num>08</num>
      <num>09</num>
      <num>10</num>
    </nums>
    

    three files: c:\xml\doc1 , c:\xml\doc2 and c:\xml\doc3 are created with the wanted contents.

    The same example using <exslt:document>:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:ext="http://exslt.org/common"
      extension-element-prefixes="saxon" >
    
     <xsl:template match="/">
      <xsl:for-each select="/*/*[not(. > 3)]">
       <ext:document href="c:\xml\doc{.}">
        <xsl:copy-of select="."/>
       </ext:document>
      </xsl:for-each>
     </xsl:template>
    </xsl:stylesheet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XSLT which will split large xml file into multiple xml file
I would like to use xslt to transform an xml file into an almost
I have an XSLT transform issue: style=width:{Data/PercentSpaceUsed}%; And the value of Data/PercentSpaceUsed is integer
Next question: I have InputDoc xml document and xslt file in order to transform
I want to transform a large xml file to sql statements with xslt. For
I have an XML file that I want to transform using an XSLT. It
I have an XSLT file <xsl:stylesheet version=1.0 xmlns:xsl=http://www.w3.org/1999/XSL/Transform> <xsl:output method=html indent=yes/> <xsl:strip-space elements=*/> <xsl:param
I have this xslt stylesheet, in file Empty.xslt: <xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:msxsl=urn:schemas-microsoft-com:xslt xmlns:nrki=http://www.essox.cz/xslt/nrki xmlns:date=http://www.essox.cz/xslt/date version=1.0
I have a list (list1) with the file names: C:\\Work\\Server1\\CSRegWeb\\Transform\\Faq.xslt C:\\Work\\Server1\\CSRegWeb\\Content\\Axxess.xml C:\\Work\\Server1\\CSRegWeb\\kleenex.aspx C:\\Work\\Server1\\CSRegWeb\\Content\\dell.xml I
I have an XSLT transform I am using to process an XML file, inserting

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.