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

Re: Image in XSL?

Subject: Re: Image in XSL?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 04 Aug 2000 20:47:54 +0100
image in xsl
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

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.