HOME>WEBプログラム覚書>XSLT xsl:element エレメント

XSLT xsl:element エレメント

XSLTでHTML要素を作成するにはxsl:element エレメントを利用する。属性はxsl:attributeエレメントで作成する。

書式


<xsl:element name="作成する要素名">
 <xsl:attribute name="作成する属性名">属性の値</xsl:attribute>
</xsl:element>

XSLTサンプル


<xsl:for-each select="affiliate/shop">
 <h4>
  <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="name" />
  </xsl:element>

  <xsl:element name="img">
   <xsl:attribute name="border">0</xsl:attribute>
   <xsl:attribute name="width">1</xsl:attribute>
   <xsl:attribute name="height">1</xsl:attribute>
   <xsl:attribute name="src"><xsl:value-of select="img" /></xsl:attribute>
  </xsl:element>
 </h4>
 <p><xsl:value-of select="comment" /></p>
</xsl:for-each>

実行結果

投稿日 2008年1月10日 23:12
カテゴリ XML
トラックバック URL http://www.kantenna.com/cgi-bin/mt504/mt-tb.cgi/1118

コメント

コメントする
Name
Email Address
URL