XHTML XML XSLT and the Img tag

I am trying to make my code compliant as XHTML.

The validator at http://validator.w3.org had trouble validating a page and when I looked at the code I found why. The output is as follows:

<div><img src="closed.gif" alt="close" id="a1">Details</div>

The problem is that there is no close for the image tag. But if you look at the XSL there is a problem. Within the div tags there is a image start tag and then an xsl attribute to set the ID for the image. Then there needs to be an image close tag but that does not exist in the HTML language, my code cannot be compliant without it. What a dilemma!

<div><img src="closed.gif"><xsl:attribute name="id">a<xsl:value-of select="@Menu"></xsl:value-of></xsl:attribute></img><xsl:value-of select="@Desc"/></div>      
blindbullAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

riyasjefCommented:
Hi
Close the img tag Like this
<div><img src="closed.gif" alt="close" id="a1" />Details</div>

RJ
0
MMeijerCommented:
in XSLT the image tag is closed but the result displays different..
normally XSLT element transformations without any "childNodes" will result in an empty element <element />

what kind of XSLT processor is used?! :)

(the "alt" attribute is mandatory on an img element in XHTML)
0
eyeh8uCommented:
Change the output to output strict XHTML in the XSL stylesheet

<!-- Force the output to be strict XHTML -->
      <xsl:output method="xml" indent="yes" encoding="iso-8859-1"
            doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
            doctype-public="-//W3C//DTD XHTML 1.0//EN"
      />
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

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.