|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: using default params?
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








