xsl-list
[Top] [All Lists]

[xsl] Alternate syntax

2007-05-18 12:05:17
Hey list,

Keep in mind, I'm open to the smallest suggestions on anything below,
even if unrelated.

Anyway, I have the following snippet:

<xsl:variable name="warning">
        <warning>New contacts may only be added to active consumers.</warning>
</xsl:variable>
<xsl:call-template name="warning">
        <xsl:with-param name="warning" select="$warning" />
       <xsl:with-param name="level">3</xsl:with-param>
</xsl:call-template>

I don't like it. I'd rather do it in one fell swoop, a la:

<xsl:call-template name="warning">
        <xsl:with-param name="warning">
        <warning>New contacts may only be added to active consumers.</warning>
      </xsl:with-param>
       <xsl:with-param name="level">3</xsl:with-param>
</xsl:call-template>

But my template complains: Reference to variable or parameter
'warning' must evaluate to a node list.

Template below.
        <xsl:template name="warning">
                <xsl:param name="warning"
select="document(concat($root,'/warning.asp?userID=',$userID))/Records/Record"
/>
                <xsl:param name="level" >
                        <xsl:choose>
                                <xsl:when test="number($warning/level) = 
$warning/level">
                                        <xsl:value-of select="$warning/level" />
                                </xsl:when>
                                <xsl:otherwise>2</xsl:otherwise>
                        </xsl:choose>
                </xsl:param>
                <xsl:if test="$warning">
                        <span class="screen">
                                <fieldset class="warning{$level}">
                                        <ul>
                                                <xsl:for-each 
select="$warning/warning">
                                                        <li><xsl:copy-of select="." 
/></li>
                                                </xsl:for-each>
                                        </ul>
                                </fieldset>
                        </span>
                </xsl:if>
        </xsl:template>

Also, I'm all about syntax efficiency. Are there any other shortcuts I
could take besides the one I'm looking for?

-Steve

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>