Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Default values of template parameters

From: David Carlisle <davidc@--------->
To:
Date: 8/1/2006 11:13:00 AM
<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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent