This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: If vs. apply-templates for optional attributes


>  <testelement>>
>               ^ you have a spare > here 

Typo while creating the e-mail...

>
>
> <xsl:template match="xxx">
> <xxx attr="default">
> <xsl:copy-of select="@*"/>
>  ..
> </xxx>
>
> which will mean that xxx has the attributes from the source, plus
> possibly attr="default" if teh source did not have that attribute.

Yes, but that doesn't help if the source also has specified the attribute.
In that case I'd end up with it defined twice...

> Note I'm not sure if that's quite what you want as your two code
> examples used different tests 
> one had not(@attr) 
> and the other had "@attr != ''
> attr=""
> would be false for both of those. Which you want depends on whether
> you want an empty attribute (as well as a missing attribute) to be
> replaced by <xxx attr="default">.

In this particular case, the attribute is either going to exist with a value
or not be specified at all, but yes, the example was a little inconsistent.
The tests can be made consistent without affecting the real question: does
the apply-templates method have any significant performance implications?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]