我在用XForms呈现我的XML文件的内容时遇到了一些问题。我没有那么多的经验,所以如果有人能给我一个提示,那就太好了。
我的XML看起来像这样:
<schedule>
<day>
<course>
</course>
<course>
</course>
..
</day>
<day>
<course>
</course>
..
</day>
..
</schedule>如果我说
<xforms:repeat nodeset="day/course" id="whatever">
<!-- here handling of nodes -->
</xforms:repeat>我只得到了每个day...How的第一个课程,我应该改变它,这样我就可以得到一天中所有课程的节点了吗?
谢谢
发布于 2011-02-09 02:29:22
您在那里的重复应该遍历所有<day>的所有<course>。例如,下面显示:数学、物理、英语、历史。
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xhtml:head>
<xhtml:title>Repeat</xhtml:title>
<xforms:model>
<xforms:instance>
<schedule>
<day label="Monday">
<course label="Math"/>
<course label="Physics"/>
</day>
<day>
<course label="English"/>
<course label="History"/>
</day>
</schedule>
</xforms:instance>
</xforms:model>
</xhtml:head>
<xhtml:body>
<xforms:repeat nodeset="day/course">
<xhtml:div>
<xforms:output value="@label"/>
</xhtml:div>
</xforms:repeat>
</xhtml:body>
</xhtml:html>但通常情况下,您要做的是首先迭代几天,然后遍历课程,如下所示:
<xforms:repeat nodeset="day">
<xhtml:div>
Day: <xforms:output value="@label"/>
<xforms:repeat nodeset="course">
<xhtml:div>Course: <xforms:output value="@label"/></xhtml:div>
</xforms:repeat>
</xhtml:div>
</xforms:repeat>https://stackoverflow.com/questions/4930975
复制相似问题