输出html控件-动态控件名称
我希望使用xslt输出html控件,但我需要能够命名控件,以便在表单发回时能够找到它们 我想能够命名单选按钮输出html控件-动态控件名称,html,xslt,xslt-1.0,Html,Xslt,Xslt 1.0,我希望使用xslt输出html控件,但我需要能够命名控件,以便在表单发回时能够找到它们 我想能够命名单选按钮“action”+\u case\u id <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="data.xsl"?> <NewDataSet> <Cases> <Case> <case_id>
“action”+\u case\u 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>
30
您的操作:
没有要报告的内容
备忘录
30
行动_
您的操作:
没有要报告的内容
备忘录
注:未测试。您可能需要专门为案例节点添加匹配器,而不仅仅是在根节点上进行匹配。在引用变量时,您需要在变量前面加一个$符号:
<input type="radio" name="{$actionid}" value="No" checked ="true"/> nothing to report<br />
无需报告
使用:
如果xml文档发生更改,可能需要用更详细的位置步骤替换上面的“*”字符。您的数据集有一个很好的特性,即它是一棵树,每个节点都可以通过它在树中的路径来识别。我认为最好的方法是以反映以下内容的方式命名对应于每个XML节点的控件:
<xsl:variable name="parent1Name"
select="name(parent::*)" />
<input type="radio" name="{concat('action_', /*/*/*/case_id)}"
value="No" checked ="true"/>
<xsl:variable name="parent1Name"
select="name(parent::*)" />