我想使用 xslt 输出 html 控件,但我需要能够命名控件,以便在表单回发时我可以找到它们。
我希望能够将单选按钮命名为 "action_"+ _case_id
。
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<NewDataSet>
<Cases>
<Case>
<case_id>30</case_id>
</Case>
<Cases>
</NewDataSet>
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div class="your_action">
Your action:<br />
<input type="radio" name="?" value="No" checked ="true"/> nothing to report<br />
<input type="radio" name="?" value="Yes" /> memo to follow
</div>
</xsl:template>
</xsl:stylesheet>
最佳答案
使用:
<input type="radio" name="{concat('action_', /*/*/*/case_id)}" value="No" checked ="true"/>
如果您的 xml 文档发生变化,可能需要用更详细的位置步骤替换上面的“*”字符。
关于html - 输出 html 控件 - 动态控件名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/337183/