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

Re: Default values of template parameters

Subject: Re: Default values of template parameters
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 1 Aug 2006 12:12:53 +0100
Re:  Default values of template parameters
	<xsl:param name="linestyle" select="Solid" />

that selects the <Solid> child element of the current node. I suspect
taht you want a default of
	<xsl:param name="linestyle" select="'Solid'" />

	<xsl:variable name="UnusedParamsA" select="0,0,1,300," />
that's an XPath1 syntax error, your stylesheet shouldn't compile, I
suspect that you again want
	<xsl:variable name="UnusedParamsA" select="'0,0,1,300,'" />




   Is there a way to pass the parameter if the tested attribute exists and
   not pass anything, not even an empty string, if it does not?
only by putting the call-template inside each branch of an xsl:choose,
and passing the param in one case and not in the other.

I would however write

<xsl:with-param name="linestyle" >
	<xsl:choose>
		<!-- if a linestyle is specified...-->
		<xsl:when test="[@name =$MatchedEntityName]/@linestyle">
                               ^^^ again that is a syntax error
                               you can't start an xpath with [

			<!-- ... pass it's value, otherwise... -->
			<xsl:value-of select="$MatchedEntityName]/@linestyle " />
		</xsl:when>
		<xsl:otherwise>
			<!-- pass nothing. -->
			<xsl:value-of select="''"/>
		</xsl:otherwise>
	</xsl:choose>
</xsl:with-param>

as
<xsl:with-param name="linestyle"  select=*[@name=$MatchedEntityName]/@linestyle"/>

then you are always passing $linestyle either with the correct value or
with an empty node set, so your template can go (I'm assuming you want a
* at the start of taht xpath)

<xsl:choose>
 <xsl:when test="$linestyle"><xsl:value-of select="$linestyle"/></xsl:when>
 <xsl:otherwise>Solid</xsl:otherwsie>

David

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.