【发布时间】:2011-10-28 21:53:27
【问题描述】:
我有 2 个文件。
1->index.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Includes -->
<xsl:include href="navigation.xsl" />
<xsl:include href="head.xsl" />
<xsl:template match="/">
<!-- WANT TO PASS THIS VARIABLE TO navigation.xsl-->
<xsl:variable name="value" select="1"/>
<!-- WANT TO PASS THIS VARIABLE TO navigation.xsl-->
<html>
<head>
<!-- Basic -->
<xsl:call-template name="HtmlBasicHead"/>
<!-- Seo -->
<title>Impress</title>
<meta name="description" content="..." />
<meta name="keywords" content="..." />
</head>
<body>
<div id="main">
<xsl:call-template name="Header"/>
<xsl:call-template name="NavigationMenu"/>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
2->导航.xsl
<xsl:template name="NavigationMenu">
<!-- NAVIGATION MENU BEGIN -->
<div id="tray">
<ul>
<xsl:if test="$value='1'">
VALUE IS 1
</xsl:if>
<li id="tray-active"><a href="#">Homepage</a></li>
<li><a href="#">Live demo</a></li>
<li><a href="#">About product</a></li>
<li><a href="#">Testimonials</a></li>
<li><a href="#">Download</a></li>
<li><a href="#">Purchase</a></li>
</ul>
<!-- NAVIGATION MENU END -->
</xsl:template>
我想要做的是在 index.xsl 中声明变量,并且仍然在 navigation.xsl 中通过调用模板使用它,因为我收到了一个错误,比如“变量‘值’没有被声明。” ....
我这样做的原因是因为我需要指定应该突出显示的按钮。
谢谢!
【问题讨论】: