XHTML XML XSLT and the Img tag

Posted on 2004-11-09
Medium Priority
Last Modified: 2013-12-16
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>      
Question by:blindbull

Expert Comment

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


Expert Comment

ID: 12539072
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)

Accepted Solution

eyeh8u earned 1000 total points
ID: 12542577
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-public="-//W3C//DTD XHTML 1.0//EN"

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question