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

Re: using default params?

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


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.