This is another problem that I encountered when I was studying today. Do image hyperlinks to the link address to the <a> href attribute to go, but this is the label in the set of tags, it is not possible, check the "Web Programming Practice Tutorial", just know the correct solution, and now share with you.
This code runs two pictures: A.gif and b.gif.
My.xml
The following are program code:
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="mystyle.xsl"?>
<Books>
<Book ID="a001">
<Name>网络指南</Name>
<Photo>a.gif</Photo>
<Homepage>http://www.a.com</Homepage>
</Book>
<Book ID="a002">
<Name>局域网技术</Name>
<Photo>b.gif</Photo>
<Homepage>http://www.b.com</Homepage>
</Book>
</Books>
Mystyle.xsl
The following are program code:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Books/Book">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="./Homepage"/>
</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="./Photo"/>
</xsl:attribute>
</xsl:element>
</xsl:element>
<br/>
</xsl:template>
</xsl:stylesheet>
Display results on browsers:
The vertical equal column displays two pictures.
Description
Using hyperlinks, you need <xsl:element> and <xsl:attribute> two tags, the basic use of the method can refer to the above example, in the esoteric, if you want to come out, remember to share yo.
Long experience, hey, this is really the first time to see.
{Homepage}
<xsl:value-of select= "Homepage"/>
The two are equivalent at all times, right?
Your top code and my original effect a little different, I help you improve it:
mystyle.xsl
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Books/Book">
<a href="{Homepage}">
</a>
</xsl:template>
</xsl:stylesheet>