|
Subject: Re: Image in XSL? From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Fri, 04 Aug 2000 20:47:54 +0100 |
Joe,
Just a few quick tips:
As you aren't renaming any of the attributes,
<img>
<xsl:attribute name="src">
<xsl:value-of select="image-clear1/@src" />
</xsl:attribute>
<xsl:attribute name="width">
<xsl:value-of select="image-clear1/@width" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="image-clear1/@height" />
</xsl:attribute>
</img>
could more easily be written as:
<img>
<xsl:copy-of select="image-clear1/@src |
image-clear1/@width |
image-clear1/@height" />
</img>
In other words, make copies of the 'src', 'width' and 'height' attributes
of 'image-clear1' to be placed in the new 'img' element.
If image-clear1 only defines src, width and height attributes (as it did in
your example), then you could do:
<img>
<xsl:copy-of select="image-clear1/@*" />
</img>
In other words, make copies of all the attributes on image-clear1.
Since you're dealing with 'image-clear1', 'image-clear2' and 'image-logo'
in almost exactly the same way, it may be worth creating a template that
does the same thing for each:
<xsl:template match="image-clear1 | image-clear2 | image-logo">
<!-- or match="*[starts-with(name(), 'image-')]" -->
<img>
<xsl:copy-of select="@*" />
</img>
</xsl:template>
And then applying it to the separate nodes explicitly within your table:
<table>
<xsl:for-each select="homepage/pagecontents/top">
<tr>
<td><xsl:apply-templates select="image-clear1" /></td>
<td><xsl:apply-templates select="image-clear2" /></td>
<td valign="top" align="left">
<xsl:apply-templates select="image-logo" />
</td>
</tr>
</xsl:for-each>
</table>
Sorry, I know you weren't looking for a critique, but I just couldn't help
myself :)
Cheers,
Jeni
Dr Jeni Tennison
Epistemics Ltd * Strelley Hall * Nottingham * NG8 6PE
tel: 0115 906 1301 * fax: 0115 906 1304 * email: jeni.tennison@xxxxxxxxxxxxxxxx
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Image in XSL?, Joe McDonald | Thread | RE: Image in XSL?, CBayes |
| Re: Complex Path Checking, Arie Golos | Date | RE: Saxon VS XT, Chris Bayes |
| Month |