topics
一言メモ
selectタグをJavascriptで生成したとき、IE6だけsize属性が1になっちゃう。そりゃないぜ!止む無くsetTimeoutで切り抜けた【一言集】

ホーム > マークアップ > xslt > 動作確認

動作確認

実際に、簡単なサンプルを用いて、xml文書がどのように変化するのか見てみます。

sample.xml

<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet href="sample.xsl" type="text/xsl"?>
<CD>
<title>to tell the truth</title>
<song>all in the mind</song>
<type>エモ・哀愁</type>
</CD>

sample.xsl

<?xml version="1.0" encoding="Shift_JIS"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="CD">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>

<xsl:template match="title">
<h1><xsl:value-of select="." /></h1>
</xsl:template>

<xsl:template match="song">
<p><xsl:value-of select="." /></p>
</xsl:template>

<xsl:template match="type">
<p><xsl:value-of select="." /></p>
</xsl:template>

</xsl:stylesheet>

出力結果

<html>
<body>
<h1>to tell the truth</h1>
<p>all in the mind</p>
<p>エモ・哀愁</p>
</body>
</html>

この記事に関するご意見・ご感想をお待ちしております。

お名前:


xsltに関する記事一覧


ナビゲーション