Another problem encountered when studying, making imagesHyperlinkTo make Put the link address in the href attribute of , but this means putting tags within tags, which is not allowed. I checked the "Web Programming Practical Tutorial" and found out the correct solution. Now I will share it with you. This code requires two images: a.gif and b.gif.
This code requires two images: a.gif and b.gif
my. xml
The following content is the 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 content is the 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>
The display result on the browser:
Display two pictures in vertical rows
Instructions:
To use hyperlinks, you need to use the two tags of
Long experience, hey, this is the first time I have seen it.
{Homepage}
Are the two equivalent at any time?
The code above is slightly different from my original effect. Let me 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}"> <img src="{Photo}"/> </a> </xsl:template> </xsl:stylesheet>
The above is the detailed content of xml image hyperlink production code. For more information, please follow other related articles on the PHP Chinese website!