xsl-list
[Top] [All Lists]

multiple outputs

2004-02-17 21:42:43
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