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

Tree Fragment - How do I test it AND output it?

Subject: Tree Fragment - How do I test it AND output it?
From: "David Penton" <dpenton@xxxxxxxxxxxxx>
Date: Tue, 18 Dec 2001 00:08:17 -0500
david penton
How do I both test the "return" value from a template, and output some of
the result nodes?  I have written a recursive template that is intended to
"draw" some xml as svg.  The template must do some calculations about the
depth of the input xml, and about its "width" (i.e. how many children a
particular node has.  My problem is that I do not know how to both get a
"return" value from a template that I can test (i.e. treating the named
template like a kind of function), and also get output from it:

Roughly, I want to do this:

<xsl:template name="namedTemplate">
    <svg> ... here is some stuff
         I actually want to output, because I'm drawing svg.
    </svg>

   <!--
        but I need to compute a value via a recursive call
        to this same template:
    -->

        <xsl:variable name="resultFromTemplate">
            <xsl:call-template name="namedTemplate">
        </xsl:variable>

        <!-- and use the "returned" value: -->

        <xsl:if test="$resultFromTemplate != 0"> ...</xsl:if>

   <!--
        Here I'll "return" a value computed in this
        named template, to control processing in the calling
        template (i.e. the earlier instance of this same one):
    -->

    <xsl:value-of select="$somethingCalculatedHere"/>

</xsl:template>


Is there a way to do this?  I suppose, to get at the results, I shall have
to convert to a nodelist.  But I don't really see how to both use the tree
as a return value, and also to output it.

Does this make sense?

- Dave Penton -


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


Current Thread

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.