导入的样式表中的XSLT样式表参数 [英] XSLT stylesheet parameters in imported stylesheets

查看:145
本文介绍了导入的样式表中的XSLT样式表参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为导入的样式表的参数赋值?

Is it possible to assign a value to a parameter of an imported stylesheet?

我原来期待

<xsl:import ... >
  <xsl:with-param ... 
</xsl:import>

但不允许这样做。

样式表参数中也禁止使用tunnel =yes。

Also tunnel="yes" is forbidden in stylesheet parameters.

推荐答案

试试这个:

main.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="import.xsl"/>

  <xsl:variable name="param" select="'some-value'"/>

  <xsl:template match="/">
    <xsl:call-template name="foo"/>    
  </xsl:template>

</xsl:stylesheet>

import.xsl

import.xsl

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>

  <xsl:param name="param" select="'default'"/>

  <xsl:template name="foo">
    <out><xsl:value-of select="$param"/></out>    
  </xsl:template>

</xsl:stylesheet>

导入样式表中的xsl:变量可以覆盖导入样式表中的xsl:param,这个有效地设置参数的值。

An xsl:variable in an importing stylesheet can override an xsl:param in an imported stylesheet, and this effectively sets the value of the parameter.

这篇关于导入的样式表中的XSLT样式表参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆