繁体   English   中英

在HTML属性中使用XSL参数值

[英]Use XSL param value in HTML attribute

我有如下形式

        <form method="get"  action="change"  target="frame">
            <select name="fill" >
                <option>red</option>
                <option>green</option>
                <option>yellow</option>
                <option>pink</option>                                   
            </select>

        <input type="submit" value="darstellen"/>
        </form>

        <iframe name="frame">

        </iframe>

我希望表单将颜色发送到另一个包含矩形的XSL文件。 到目前为止,将颜色传递到其他XSL文件的工作正常,但现在我想动态更改矩形的填充颜色,但使用传递的参数将无法工作。

<map:match pattern="change">

<map:generate src="square.svg"/>

<map:transform src="recchange.xsl">

    <map:parameter name="use-request-parameters" value="true"/>

</map:transform>

<map:serialize type="html"/>

这是我的站点地图

<xsl:param name="fill"/>
<xsl:output method="html"/>

<xsl:template match="/">
<html>
    <body>

        <h2><xsl:value-of select="$fill"/></h2>
        <h1>testtest</h1>
        <svg>
              <rect width="300" height="100" style="fill:$fill;stroke-width:3;stroke:red">
              </rect>
        </svg>

这是我到目前为止尝试过的。 有人有建议吗?

您可以在此处使用“ 属性值模板”来评估$fill变量并将其值直接输出到属性字符串中

 <rect width="300" height="100" style="fill:{$fill};stroke-width:3;stroke:red">

因此,花括号在此处表示属性值模板。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM