I'm teaching myself XSLT and am still trying to wrap my brain around the small details. I have a template in my XSL stylesheet that looks like this...
<td><img src="{normalize-space(image)}"/></td>
which produces XHTML that looks like this...
<td><img src="开发者_如何学Pythonsomefile.jpg"></td>
How do I change my XSL template to add a trailing "/" to the img tag so that the XHTML output looks like this...
<td><img src="somefile.jpg"/></td>
Also, why does the trailing slash in the template get omitted in the output?
Thanks in advance for all your help!
I would start with this:
<xsl:output method="xml" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" indent="yes"/>
This will get your XSL parser to close empty tags correctly since you are (technically) producing XML. HTML does not have the concept of an empty tag like XML/XHTML does.
You could also do:
<xsl:element name="img">
<xsl:attribute name="src">blarg</xsl:attribute>
</xsl:element>
which will output <img src="blarg"/>
精彩评论