XSLT <xsl:strip-space>
❮完全なXSLT要素リファレンス
定義と使用法
<xsl:strip-space>要素は、空白を削除する要素を定義するために使用されます。
注:空白を保持することがデフォルト設定であるため、<xsl:preserve-space>要素を使用する必要があるのは、<xsl:strip-space>要素が使用されている場合のみです。
注: <xsl:preserve-space>要素と<xsl:strip-space>要素は最上位の要素です。
構文
<xsl:preserve-space elements="list-of-element-names"/>
<xsl:strip-space elements="list-of-element-names"/>
属性
Attribute | Value | Description |
---|---|---|
elements | list-of-element-names | Required. A white space separated list of element names for which white space should be preserved/removed. Note: The list can also contain "*" and "prefix:*" so that all elements or all elements from a particular namespace can be joined |
例1
以下の例では、タイトルとアーティストの要素の空白ノードを保持し、国、会社、価格、年の要素の空白ノードを削除します。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="country company price year" />
<xsl:preserve-space elements="title artist" />
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="catalog/cd">
<p>
<xsl:value-of select="title" /><br />
<xsl:value-of select="artist" /><br />
<xsl:value-of select="country" /><br />
<xsl:value-of select="company" /><br />
<xsl:value-of select="price" /><br />
<xsl:value-of select="year" />
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
❮完全なXSLT要素リファレンス