[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: multiple outputs

Subject: RE: multiple outputs
From: cknell@xxxxxxxxxx
Date: Wed, 18 Feb 2004 07:19:47 -0500
xsl multiple outputs
It's not clear from your message, but I think you are looking to serialize more than one document from a single transformation. This is not provided for in XSL 1.0. Some processors implement this as an extension, so whether or not this can be done depends on which XSL processor you use. How the extension is called will vary from processor to processor, so check the docs on yours to find out if this is possible and how it is done. This is a FAQ, so search this list's archives for answers.

Now a comment on your style. Based on the question and the use of <xsl:for-each> in your stylesheet, I surmise that you are relatively new to XSLT. You will be well served to spend the time to incorporate XSLT's programming worldview into your own thinking. Search the archives for "push model" and "pull model". XSLT is more like SQL than it is like C. That is to say, your templates should describe what is to be done and not how to do it. The primary use <xsl:for-each> is to permit sorting rather than to loop through sets of elements as you would in an imperative language.
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     Shadab <mohammad.shadab@xxxxxxxxxxx>
Sent:     Wed, 18 Feb 2004 10:12:43 +0530
To:       <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Subject:   multiple outputs

Hi,

I am having problem creating xsl which would render multiple outputs from a
single source file.

eg.

say source xml is:

<Root>
<Record><one>1</one></Record>
<Record><one>2</one></Record>
</Root>

and xsl is:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
    <xsl:template match="/">
        <Sheet>
             <xsl:for-each select="Root/Record">

                <xsl:if test="one=1">
                <sheet1>
                  <col1>
                    <xsl:value-of select="one"/>
                 </col1>
                </sheet1>
               </xsl:if>

                <xsl:if test="one=2">
                <sheet1>
                  <col1>
                    <xsl:value-of select="one"/>
                 </col1>
                </sheet1>
               </xsl:if>
                <!--for both conditions the output has to be sent to
different stream and output should be from root downwards.-->

            </xsl:for-each>
        </Sheet>
    </xsl:template>
</xsl:stylesheet>

now based on the 'if' condition applied below the 'for' loop the output is
to be redirected to different output streams.

So one solution is to have a sequence of ifs to direct output using
different result fragments but this will only send a fragment of the output
to the stream and not the whole well formed xml starting from <Sheet>
downwards.

so two outputs could be

<Sheet>
     <col1>1</col1>
<Sheet>

and

<Sheet>
    <col1>2</col1>
<Sheet>

Any ideas how to have the complete output in any number of streams based on
conditions which may not be at root level but further down.

Thanks,
Shadab


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • RE: multiple outputs
    • cknell - Wed, 18 Feb 2004 07:20:09 -0500 (EST) <=
      • Shadab - Wed, 18 Feb 2004 08:34:05 -0500 (EST)
      • <Possible follow-ups>
      • cknell - Wed, 18 Feb 2004 09:39:17 -0500 (EST)
      • Joseph Kesselman - Wed, 18 Feb 2004 11:16:53 -0500 (EST)

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.