・<xsl:element name="a">でHTMLの<a>タグを生成し、<xsl:attribute>を使い、<a>タグのhref属性を設定する。(例
1)
・<xsl:element name="a">でHTMLの<a>タグを生成する代わりに、<a>タグを直接記述してもよい。(例
2)
・より簡単にリンクを作成するには、属性テンプレート{}を利用すれば便利・・・→「参照」
[サンプルXML文書を表示](下のフレームに)
XMLソース
<?xml version="1.0" encoding="Shift_JIS" ?> <?xml-stylesheet type="text/xsl" href="link01.xsl"?> <start> <top>KodayanHomepageのサイト構成</top> <contents> <link> <title>大阪日本橋DOS/Vプロムナード</title> <url>../../dosv/dosv.htm</url> </link> <link> <title>CSSとDynamicHTML</title> <url>../../dhtm/frameset.htm</url> </link> <link> <title>PerlでCGI</title> <url>../../cgi/cgifset.htm</url> </link> </contents> <end>以上です(03/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="/">
<H3><center><xsl:value-of select="start/top"/></center></H3>
<xsl:apply-templates select="start/contents"/>
</xsl:template>
<xsl:template match="start/contents">
<h4>例 1</h4>
<xsl:for-each select="link">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="url" />
</xsl:attribute>
<xsl:attribute name="target">
_blank
</xsl:attribute>
<xsl:value-of select="title" /><BR/>
</xsl:element>
</xsl:for-each>
<hr/>
<h4>例 2</h4>
<xsl:for-each select="link">
<a>
<xsl:attribute name="href">
<xsl:value-of select="url" />
</xsl:attribute>
<xsl:attribute name="target">
_blank
</xsl:attribute>
<xsl:value-of select="title" /><BR/>
</a>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
end(03/11/18)