Re: using default params?

Subject: Re: using default params?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 29 Mar 2000 11:07:32 GMT

> the syntax
> choose-when-/when-otherwise-/otherwise-/choose is more than a little
> bit stupid for this...

It's an XML feature.
If you close your eyes, the syntax doesn't look so bad.

> this I don't understand.
As Paul commented, your understanding wasn't helped by me messing up the
example. 
>  what if I want to do something like 
> <table bgcolor="#ff0000" border="1"> and have both overridden?

<table bgcolor="#ff0000" border="1">
<xsl:if test="@foo">
  <xsl:attribute name="bgcolor"><xsl:value-of select="@foo"/></xsl:attribute>
</xsl:if>
<xsl:if test="@bar">
  <xsl:attribute name="border"><xsl:value-of select="@bar"/></xsl:attribute>
</xsl:if>



> And I don't understand this, too :-(
> why don't you need a test for existence in this example around the
> xsl:copy-of ?

'cause <xsl:copy-of select="@bgcolor"/> copys the nodes it selects
and if there isn't a bgcolor attribute node, that isn't an error
you just get the empty node set so nothing in the output.

People often go in a template

<table border="{@border}">

hoping to copy the border attribute from some input table to an output
table but that is only ok if the input attribute is always there,
otherwise you get border="".
better to go

<table border>
  <xsl:copy-of select="@border"/>

or if you want as in your case to supply a default


<table border border="1001! >
  <xsl:copy-of select="@border"/>


except you also want to change the name of the attribute so you have to
go back to testing.


David


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread