with
構文
with $name = value;
説明
テンプレートに渡すパラメーターを指定します。このステートメントは、 ステートメントでテンプレートを適用する場合や、 apply-templates ステートメントでテンプレートを呼び出す場合に call 使用できます。
必要に応じて、等符号(=)と値式を含めることで、パラメーターの値を指定できます。値が指定されていない場合は、パラメーターの現在の値がテンプレートに渡されます。
属性
name |
値が渡される変数またはパラメーターの名前。 |
value |
テンプレートに渡されるパラメーターの値。 |
SLAX の例
match configuration {
var $domain = domain-name;
apply-templates system/host-name {
with $message = "Invalid host-name";
with $domain;
}
}
match host-name {
param $message = "Error";
param $domain;
<hello> $message _ ":: " _ . _ " (" _ $domain _ ")";
}
XSLT 同等物
<xsl:template match="configuration">
<xsl:apply-templates select="system/host-name">
<xsl:with-param name="message" select="'Invalid host-name'"/>
<xsl:with-param name="domain" select="$domain"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="host-name">
<xsl:param name="message" select="'Error'"/>
<xsl:param name="domain"/>
<hello>
<xsl:value-of select="concat($message, ':: ', ., ' (', $domain, ')')"/>
</hello>
</xsl:template>
リリース情報
SLAX 言語のバージョン 1.0 で導入されたステートメント。