簡體   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