Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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'?>
       <name>Black Headlight</name>
       <name>Red Headlight</name>

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="">
<xsl:template match="/">
      <title>Test XSL sheet</title>
      <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>

  • 2
  • 2
1 Solution
Use this:
<xsl:attribute name='src'>
  <xsl:value-of select="image"/>
<xsl:attribute name='height'>100</xsl:attribute>
<xsl:attribute name='width'>200</xsl:attribute>
yeelanAuthor Commented:
why <img> don't need to write like this?

<xsl:element name="img">  ?
you can yeelan..but it is redundant
yeelanAuthor Commented:
Thank you very much, gsatsan
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now