属性値テンプレート2

・{}を複数連記できる
  (例)<img src="{img/folda}{file}{拡張子}"/>
・{XPath式}以外の文字列を併記できる
  (例)<img src="../{img/file}.jpg"/>

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

XMLソース

<?xml version="1.0" encoding="Shift_JIS" ?>
<?xml-stylesheet type="text/xsl" href="attribute06.xsl"?>
<root>
<title>属性値テンプレートのテスト</title>
<data>
<test1 スタイル1="color:green;" スタイル2="font:bold italic 18px">例1)複数の{}を連記する</test1>
<test2 スタイル="font:bold italic 18px">例2){XPath式}以外の文字列を併記</test2>
<test3>例3)
<画像>
<フォルダ>images/cut/</フォルダ>
<imgfile width="70" height="80">025</imgfile>
<拡張子>gif</拡張子>
<alt>{}を利用しHTML属性を生成する例</alt>
</画像>
</test3>
</data>
</root>

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><H4><xsl:value-of select="root/title"/></H4></center>
<xsl:apply-templates select="root/data"/>
</xsl:template>

<xsl:template match="data">
<p style="{test1/@スタイル1}{test1/@スタイル2}"><xsl:value-of select="test1"/></p>
<p style="color:red;{test2/@スタイル}"><xsl:value-of select="test2"/></p>
例3)
<img border="0"
src="../../{test3/画像/フォルダ}{test3/画像/imgfile}.{test3/画像/拡張子}"
width="{test3/画像/imgfile/@width}" height="{test3/画像/imgfile/@height}"
alt="説明:-→「{test3/画像/alt}」">
</img>
</xsl:template>
</xsl:stylesheet>

end(新規:04/12/8)