// 下階層用テンプレート
#topicpath
----
//ここにコンテンツを記述します。

***XMLファイルに、XSLスタイルシートを関連づけ。
 <?xml-stylesheet type="text/xsl" href="midashi.xsl" ?>


***アンカーをつける
 <a><xsl:attribute name="name">code-<xsl:value-of select="code" /></xsl:attribute></a>
とすると、
 <a name="code-6758" />
となる(6758はcode要素の値)。

#navi(XML)
***アンカーへのリンクを張る
 <a><xsl:attribute name="href">#code-<xsl:value-of select="code" /></xsl:attribute><xsl:value-of select="code" /></a>
とすると
 <a href="#code-6758">6758</a>
となる。

***繰り返し処理で、最後以外にカンマをつける
よくある処理なので、まとめておきます。
 <xsl:template match="security">
 	<xsl:apply-templates select="attribute" />
 	<xsl:choose>
 		<xsl:when test="position()=last()" />
 		<xsl:otherwise>,</xsl:otherwise>
 	</xsl:choose>
 </xsl:template>

***○○属性が存在するときのみ、表示する
 <xsl:if test="count(@name)!=0">属性[<xsl:apply-templates select="@name" />]</xsl:if>


***modeの使い方
XSLTの仕様にmodeという仕様があります。同じ要素名に対して、別のテンプレートを適用したいときに使用するのだと思います。
 <xsl:template match="security">
   一覧:<xsl:apply-templates select="code" />
 </xsl:template>
 
 <xsl:template match="security" mode="detail">
   詳細:<xsl:apply-templates select="code" />
 </xsl:template>

と定義しておいて
 一覧を表示したいところに <xsl:apply-templates select="security" />
 詳細を表示したいところに <xsl:apply-templates select="security" mode="detail" />



----
この記事は
#vote(おもしろかった[1],そうでもない[0])

#comment
#topicpath


SIZE(10){現在のアクセス:&counter;}


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS