xml - 在 HTML 属性中使用 XSL 参数值
问题描述
我有如下表格
<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">
因此,花括号代表此处的属性值模板。
推荐阅读
- scala - Scala:无类型的表达式。类型不确认期望类型文档
- android - 为什么我的应用在尝试连接到 Firebase 时会崩溃?
- apache-kafka - Kafka 消费者 CLI 中未显示数值
- android - 如何解析 XML 文件并使用找到的值创建对象?
- spring - 无法在 websphere 自由配置文件中创建 EntityManagerFactory
- pandas - 即使使用 inplace=True,Pandas 也无法正常工作
- reactjs - 从状态中删除对象时子组件列表未正确更新
- python - 从控制台读取未知数量的行
- c# - 如何在同一视图中创建“n”个子对象和父对象?
- wpf - 如何强制嵌入在 Expander 中的 WPF TreeView 重新排列大小?