On Thu, Oct 05, 2000 at 02:45:33PM -0700, Nikhil G. Daddikar wrote:
> Hi,
> 
> I want to do the following:
> 
> Write a template that pretty prints a date and takes in an argument
> which is the raw date. This is so that the way to print a dat is only in
> one place.
> 
> How do I do it? Looks like named templates with  parameters is not
> supported in Sablotron. Can I define some global parameters like
> PRINT_DATE_ARG which the template will use. If yes, how do I set this
> arg. Any other way is also ok.

I am using named templates with parameters all the time in 0.43 without
problems.  Stuff like the following (which probably isn't too
intelligent):


<xsl:template name='print-date'>
    <xsl:param name='datestring'/>
    <xsl:param name='element'/>
    <xsl:element name='{$element}'>
        <xsl:attribute name='Scheme'>
            <xsl:text>W3CDTF</xsl:text>
        </xsl:attribute>
        <xsl:attribute name='DateTime'>
            <xsl:value-of select='$datestring'/>
        </xsl:attribute>
        <xsl:value-of select='$datestring'/>
    </xsl:element>
</xsl:template>


...
    <xsl:choose>
        <xsl:when test="$ms='January'">
            <xsl:call-template name='print-date'>
                <xsl:with-param name='datestring'
                        select="concat($ys, '-1-', $ds)"/>
                <xsl:with-param name='element' select='$element'/>
            </xsl:call-template>
        </xsl:when>
        <xsl:when test="$ms='February'">
            <xsl:call-template name='print-date'>
                <xsl:with-param name='datestring'
                        select="concat($ys, '-2-', $ds)"/>
                <xsl:with-param name='element' select='$element'/>
            </xsl:call-template>
        </xsl:when>

I found the XSLT-Tutorial and reference at zvon.org very useful
(http://www.zvon.org/index.php?nav_id=3)

- Guenter
-- 
Guenter Radestock, Universitaetsbibliothek Karlsruhe
[EMAIL PROTECTED]
http://www.ubka.uni-karlsruhe.de/~guenter

Reply via email to