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

Re: Alternate syntax

Subject: Re: Alternate syntax
From: Steve <subsume@xxxxxxxxx>
Date: Fri, 18 May 2007 15:55:54 -0400
Re:  Alternate syntax
I don't know, but your 'warning' named template references
$warning/level, and that element is not defined in your 'warning'
variable or parameter, so you won't always get what you want anyway.

Yeah, sometimes it won't exist. That's fine.Thanks though!


Also, I don't think that test="number($warning/level) = $warning/level"
gives you what you expect either. Are you trying to compare the
warning.asp node value to the passed value?

No, just making sure its a number.



-----Original Message-----
From: Steve [mailto:subsume@xxxxxxxxx]
Sent: May 18, 2007 3:05 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Alternate syntax

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/R
ecord"
/>
                <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

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.