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

Re: how to always call a template at the end of xsl:te

Subject: Re: how to always call a template at the end of xsl:template
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Tue, 21 Oct 2003 21:46:09 +0200
xsl template mode guide
This can be achieved in an ellegant way if instead of moded templates you
use template references.

Using this approach one can call a single named template, passing as
parameters the tmplate reference to the template to be instantiated and any
parameters it might need.

This generic template will instantiate the template that matches the passed
reference. Then it will perform the common epilogue.

Generic templates and template references are the base for the FXSL library.
Read more about this approach here:


http://fxsl.sourceforge.net/articles/FuncProg/Functional%20Programming.html

and here:


http://www.idealliance.org/papers/extreme03/xslfo-pdf/2003/Novatchev01/EML2003Novatchev01.pdf



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL



"Xiaocun Xu" <xiaocunxu@xxxxxxxxx> wrote in message
news:20031021171923.83369.qmail@xxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
>   I need to log row ID for error reporting and this
> has to be done at end of all rows regardless of
> template mode.  The obvious way is to add
> <xsl:call-template name="logRowId"/> at end of each of
> the <xsl:template match="row"> regardless of mode, the
> problem is maintainence as I need to pepper this call
> to all row templates (there are a number of row
> templates with different modes) and I need to continue
> remember add this call at end of each new row template
> mode in the future.  Is there a clean way to always
> call template logRowId at end of <xsl:template
> match="row"> regardless of mode?  Sample source XML
> and XSLT below.
>
> thanks,
> Xiaocun
>
> Source XML:
> <row row="7">
> <cell column="1">host</cell>
> <cell column="3">fsc1_BA1</cell>
> <cell column="4">unacknowledged</cell>
> <cell column="5">rfx</cell>
> <cell column="7">lead</cell>
> </row>
> <row row="9">
> <cell column="1">respondent</cell>
> <cell column="2">s1</cell>
> <cell column="3">s1_AM1</cell>
> <cell column="4">unacknowledged</cell>
> <cell column="5">rfx</cell>
> </row>
>
>
> XSLT:
> <xsl:apply-templates select="//row[@row &lt; 8]"
> mode="host"/>
> <xsl:apply-templates select="//row[@row &gt; 8]"
> mode="respondent"/>
>
> <xsl:template match="row" mode="host">
> <!-- skip unnecessary details -->
> <xsl:call-template name="logRowId"/>
> </xsl:template>
> <xsl:template match="row" mode="respondent">
> <!-- skip unnecessary details -->
> <xsl:call-template name="logRowId"/>
> </xsl:template>
>
> <!-- log row ID for error reporting -->
> <xsl:template name="logRowId">
> <xsl:element name="Logs">
> <xsl:attribute name="rowID"><xsl:value-of
> select="@row"/></xsl:attribute>
> </xsl:element>
> </xsl:template>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
>  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

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.