请在下面找到我的xform页面。如何向所有子节点插入属性
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
xmlns:exforms="http://www.exforms.org/exf/1-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xhtml:head>
<xforms:instance id="instanceData">
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<fruits>
<fruit>
<fruit-name>Mango</fruit-name>
</fruit>
<fruit>
<fruit-name>Apple</fruit-name>
</fruit>
<fruit>
<fruit-name>Banana</fruit-name>
</fruit>
</fruits>
</form>
</xforms:instance>
</xhtml:head>
</xhtml:html>
我想插入一个属性味道=“好”是所有水果名称标签,如下
<fruit-name taste="good">
我尝试以下方法来达到相同的,但它总是插入属性只有第一个水果名。
<xforms:insert ev:event="xforms-model-construct-done"
context="instance('instanceData')/fruits/fruit/fruit-name"
origin="xxforms:attribute('taste','good')" />
<xforms:insert ev:event="xforms-model-construct-done"
context="instance('instanceData')/fruits/fruit[position() > 0]/fruit-name"
origin="xxforms:attribute('taste','good')" />
请建议一种方法将此属性插入镜头中的所有水果名称节点。 由于水果列表是动态的,我们需要有一个动态的解决方案。
问得好,+1。查看我的答案,获得完整,简短且容易的XSLT解决方案。 :) – 2011-03-08 04:46:15