Vosegus Sakura

  1. Home
  2. XHTML CSS ガイドライン Beta
  3. XSLT リファレンス

XSLT リファレンス

XHTML CSS ガイドライン

XML から HTML4.01 への変換

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html" version="4.01" encoding="utf-8" indent="yes" /> <xsl:template match="/"> <html lang="ja"> </html> </xsl:template> </xsl:stylesheet>

XML から XHTML への変換

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"> <xsl:output omit-xml-declaration="no" encoding="utf-8" method="xml" version="1.0" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" indent="yes"/> <xsl:template match="/"> <html lang="ja" xml:lang="ja" dir="ltr"> </html> </xsl:template> </xsl:stylesheet>

基本操作

ノードバリューの取得 <xsl:value-of select="./">
属性値の取得 <xsl:value-of select="./@attr">
要素生成 <xsl:element name=""></xsl:element>
属性値のセット <xsl:attribute name=""><xsl:attribute>
ループ <xsl:for-each select="">
</xsl:for-each>

条件分岐

条件判定 <xsl:if test=""></xsl:if>
条件分岐 <xsl:choose>
<xsl:when test="">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>

判定

ノードバリュー判定 test="ノード名[.='']"
ノードの文字列判定 test="contains(./text() , '1')"
ポジション判定 test="position() = num"
ポジションの余り判定 test="position() mod 4 = 0"

テンプレート操作

次のテンプレートへ処理を送る <xsl:apply-templates select="node/childnode"/>
<xsl:template match="node/childnode"/>
</xsl:template>
インクルード <xsl:include href="hoge.xsl" />

このページの上部へ