画像にリンクを設定

・<xsl:attribute>で属性を生成しながら、<a href=""><img src=""></img></a>形式をつくる。

[サンプルXML文書を表示](下のフレームに)

XMLソース

<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet type="text/xsl" href="link02.xsl"?>
<start>
<top>画像にリンクを設定</top>
<contents>
<link>
<画像 path="../../images/linkdosv.gif">
../../dosv/dosv.htm
</画像>
<alt>大阪日本橋DOS/Vプロムナード</alt>
</link>
<link>
<画像 path="../../images/linkcss.gif">
../../dhtm/frameset.htm
</画像>
<alt>CSSとDynamicHTML</alt>
</link>
</contents>
<end>以上です(00/11/18)</end>
</start>

XSLソース

<?xml version="1.0" encoding="Shift_Jis"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="Shift_JIS"/>
<xsl:template match="/">
<center><H3><xsl:value-of select="start/top"/></H3></center>
<HR/>
<xsl:apply-templates select="start/contents"/>
</xsl:template>

<xsl:template match="start/contents">
<xsl:for-each select="link">
<a>
<xsl:attribute name="href">
<xsl:value-of select="画像" />
</xsl:attribute>
<xsl:attribute name="target">_blank</xsl:attribute>
<img>
<xsl:attribute name="src">
<xsl:value-of select="画像/@path" />
</xsl:attribute>
<xsl:attribute name="border">0</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="alt" />
</xsl:attribute>
</img>
</a>
<xsl:value-of select="alt" />
<BR/><BR/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

end(00/11/18)