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

  • Home
  • SEARCH
  • 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 145319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:24:09+00:00 2026-05-11T08:24:09+00:00

Greetings, I’m looking for a method to do in-line result (output) document selecting in

  • 0

Greetings,

I’m looking for a method to do in-line result (output) document selecting in XSLT. I know of the method where one creates an xsl:result-document node to have one transformation apply to multiple documents. Usually this method uses several passes, such as:

<xsl:template match='/'>     <xsl:apply-templates select='*'/>     <xsl:result-document href='test.xml'>         <xsl:apply-templates select='*'/>     </xsl:result-document> </xsl:template> 

I’m looking for a way to do this inline so I can build two output documents in a single pass. The reason is I have a temporary tree that is built as the transformation is run that I want to output to a file.

<xsl:variable name='treeBase'>     <Base/> </xsl:variable>  <xsl:template match='/'>     <xsl:apply-templates select='*'/> </xsl:template>  <xsl:template match='these_elements'>     <xsl:param name='temp' select='$treeBase'/>   </xsl:template>  <xsl:template match='not_these_elements'>     <xsl:param name='temp' select='$treeBase'/>      <xsl:apply-templates select='@*|node()'>        <xsl:with-param name='temp'>            <Base>               <xsl:copy-of select='$temp/Base/*'/>               <Item>                   <xsl:value-of select='ThisItem'/>               </Item>            </Base>         </xsl:with-param> </xsl:template> 

Why would you want to do this? In my XSLT I’m building a temporary tree through recursive parameter calls. I want to output the temporary tree as it is being built to a separate document but still use the temporary tree built for flow of control. With the current method I’d have to run through a complex transformation twice.

Is there a way to do this in XSLT or is it single-pass, single-document only?

Thanks in advance.

  • 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. 2026-05-11T08:24:10+00:00Added an answer on May 11, 2026 at 8:24 am

    Here is a working example how to do this:

    This transformation:

    <xsl:stylesheet version='2.0'     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'     xmlns:xs='http://www.w3.org/2001/XMLSchema'>     <xsl:output omit-xml-declaration='yes' indent='yes'/>   <!--                                               -->         <xsl:template match='/*'>       <xsl:variable name='vTop' select='.'/>   <!--                                               -->             <xsl:for-each-group select='num' group-by='xs:integer(.) mod 2'>           <xsl:result-document href='file:///C:/Temp/file{position()}.xml'>             <xsl:element name='{name($vTop)}'>               <xsl:copy-of select='current-group()'/>             </xsl:element>           </xsl:result-document>         </xsl:for-each-group>     </xsl:template> </xsl:stylesheet> 

    when applied on this 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>010</num> </nums> 

    produces the wanted two files: file1.xml and file2.xml, which contain, correspondingly, the ‘num’ elements with odd and with even values.

    Do note that there are no ‘multiplr passes’ and the code is ‘inline’, as required.

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

Sidebar

Ask A Question

Stats

  • Questions 189k
  • Answers 189k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer New versions of Java will run code compiled in previous… May 12, 2026 at 5:51 pm
  • Editorial Team
    Editorial Team added an answer A recursive CTE like this would work, assuming your hierarchy… May 12, 2026 at 5:51 pm
  • Editorial Team
    Editorial Team added an answer I'm not sure you should be enforcing the 'at least… May 12, 2026 at 5:51 pm

Related Questions

Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings. I'm looking for a way to parse a number of XML files in
Greetings! I'm working on wrapping my head around LINQ. If I had some XML
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings, I need a way (either via C# or in a .bat file) to

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.