j_m*_*aly 14 xslt parameters import
是否可以为导入的样式表的参数赋值?
我期待着类似的东西
<xsl:import ... >
<xsl:with-param ...
</xsl:import>
Run Code Online (Sandbox Code Playgroud)
但这是不允许的.
样式表参数中也禁止使用tunnel ="yes".
Mic*_*Kay 19
试试这个:
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>
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
导入样式表中的xsl:变量可以覆盖导入样式表中的xsl:param,这有效地设置了参数的值.