xmlファイル
<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet href="test.xsl" type="text/xsl" ?>
<index>
<lastupdate>yyyy年mm月dd日</lastupdate>
<content>
<category>AAAA</category>
<subcategory>aaaa</subcategory>
<date>
<unid>http://www.test.co.jp/index1.html</unid>
<createdate>2005-02-04</createdate>
<headline>Test1</headline>
</date>
</content>
<content>
<category>AAAA</category>
<subcategory>bbbb</subcategory>
<date>
<unid>http://www.test.co.jp/index2.html</unid>
<createdate>2005-02-03</createdate>
<headline>Test2</headline>
</date>
</content>
<content>
<category>AAAA</category>
<subcategory>cccc</subcategory>
<date>
<unid>http://www.test.co.jp/index3.html</unid>
<createdate>2005-02-02</createdate>
<headline>Test3</headline>
</date>
</content>
</index>
xsltファイル
<?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="/">
<html>
<head>
<title>XSLT TEST</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="300">
<tr>
<td width="10">
<img src="common/imgs/spacer.gif" width="10" height="1" alt="" />
</td>
<td>
<h3><xsl:apply-templates mode="information" /> 最新情報</h3>
</td>
</tr>
</table>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<!-- 最新情報日付 -->
<xsl:template match="index" mode="information">
<xsl:value-of select="lastupdate" />
</xsl:template>
<!-- タイトル -->
<xsl:template match="content">
<xsl:variable name="_category">
<xsl:value-of select="category" />
</xsl:variable>
<xsl:variable name="_subcategory">
<xsl:value-of select="subcategory" />
</xsl:variable>
<xsl:element name="a">
<xsl:attribute name="name">
<xsl:value-of select="concat($_category,$_subcategory)" />
</xsl:attribute>
</xsl:element>
<h4>
<xsl:value-of select="$_category" /> <xsl:value-of select="$_subcategory" />
</h4>
<table cellspacing="1" cellpadding="4" border="1" width="300">
<xsl:apply-templates select="date" />
</table>
</xsl:template>
<!-- リンク -->
<xsl:template match="date">
<tr valign="top">
<td width="32%" class="textS">
<xsl:value-of select="createdate" />
</td>
<td class="textS">
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="unid" />
</xsl:attribute>
<xsl:value-of select="headline"/>
</xsl:element>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
htmlファイル
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<title>XSLT TEST</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="300">
<tr>
<td width="10"><img src="common/imgs/spacer.gif" width="10" height="1" alt=""></td><td>
<h3>yyyy年mm月dd日 最新情報</h3>
</td>
</tr>
</table>
yyyy年mm月dd日←ここの日付がエラー
<a name="AAAAaaaa"></a>
<h4>AAAA aaaa</h4>
<table cellspacing="1" cellpadding="4" border="1" width="300">
<tr valign="top">
<td width="32%" class="textS">2005-02-04</td>
<td class="textS"><a href="http://www.test.co.jp/index1.html">Test1</a></td>
</tr>
</table>
<a name="AAAAbbbb"></a>
<h4>AAAA bbbb</h4>
<table cellspacing="1" cellpadding="4" border="1" width="300">
<tr valign="top">
<td width="32%" class="textS">2005-02-03</td>
<td class="textS"><a href="http://www.test.co.jp/index2.html">Test2</a></td>
</tr>
</table>
<a name="AAAAcccc"></a>
<h4>AAAA cccc</h4>
<table cellspacing="1" cellpadding="4" border="1" width="300">
<tr valign="top">
<td width="32%" class="textS">2005-02-02</td>
<td class="textS"><a href="http://www.test.co.jp/index3.html">Test3</a></td>
</tr>
</table>
</body>
</html>
|