Link to home
Start Free TrialLog in
Avatar of yeelan
yeelan

asked on

display an image with fixed width and length

I know how to display an image now, but I don't know how to set its width and length. Can you show me how to write?

[xml document]
<?xml version='1.0'?>
<?xml-stylesheet type='text/xsl' href='viewdata.xsl'?>
<CATAGORY>
<product>
       <name>Black Headlight</name>
       <price>30</price>
       <image>hlight1.gif</image>
</product>
<product>
       <name>Red Headlight</name>
       <price>40</price>
       <image>hlight2.gif</image>
</product>
</CATAGORY>


[viewdata.xsl]
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
  <html>
    <head>
      <title>Test XSL sheet</title>
    </head>
    <body>
      <xsl:for-each select="/CATEGORY/Product">
        <xsl:value-of select="name"/><br/>
        <xsl:value-of select="price"/><br/>
        <img><xsl:attribute name='src'><xsl:value-of select="image"/></xsl:attribute></img>
        <br/><hr/>
      </xsl:for-each>
    </body>
  </html>
</xsl:template>
</xsl:stylesheet>

ASKER CERTIFIED SOLUTION
Avatar of gsatsan
gsatsan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yeelan
yeelan

ASKER

why <img> don't need to write like this?

<xsl:element name="img">  ?
you can yeelan..but it is redundant
Avatar of yeelan

ASKER

Thank you very much, gsatsan