我正在使用XForms構建一個帶有XML-DB eXist-db作爲後端的Web應用程序。 eXist將XForms代碼轉換爲HTML和JavaScript。XForms重複 - JavaScript錯誤
首先,我有兩個實例:
<xf:instance xmlns="" id="results">
<result>
<ServiceDefinition>
<InventoryLabel LastChange="2012-01-24">SVC380712435</InventoryLabel>
<SystemName IPaddress="111.222.333.123">XXX</SystemName>
<Service ServiceCategory="Internetservice">Web-Server</Service>
<OSClass OperatingSystem="CentOS">UNIX</OSClass>
<SystemType Manufacturer="VMware">VM</SystemType>
<Backup/>
<Location SystemContact="Max Power" AdminGroup="power">N22</Location>
</ServiceDefinition>
....
</result>
</xf:instance>
<xf:instance xmlns="" id="domain">
<system name="XXX">
<NIC MAC="00-50-56-ae-00-3c"
time="1329167846" missed="1323350247" state="inactive"
IP="111.222.333.123" LAN="Test"/>
</system>
...
</xf:instance>
我想建立使用xf:repeat
通過所有的「結果」實例<ServiceDefinition>
元素遍歷表。每行都包含一個「狀態」列,我想從「域」實例中放置相關的「狀態」信息。
這是表的XForms代碼:
<div class="table">
<table border="0">
<thead>
<tr>
<th class="sysName">Hostname</th>
<th class="services">Service</th>
<th class="os">OS Class</th>
<th class="location">Location</th>
<th class="link">Details</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<xf:repeat nodeset="instance('results')/result/ServiceDefinition" id="link-repeat">
<tr>
<td class="sysName"><xf:output ref="SystemName" /></td>
<td>
<xf:repeat nodeset="Service" class="row">
<div>
<xf:output ref="."/>
</div>
</xf:repeat>
</td>
<td class="os"><xf:output ref="OSClass"/> </td>
<td class="location"><xf:output ref="Location" /></td>
<td class="link">
<xf:trigger submission="view-entry" appearance="minimal" class="url">
<xf:label>View</xf:label>
<xf:action ev:event="DOMActivate">
<xf:setvalue ref="instance('URL-container')"
value="concat('serviceDetails.xql?svc=', instance('results')/result/ServiceDefinition[index('link-repeat')]/InventoryLabel)"/>
<xf:load ref="instance('URL-container')" />
</xf:action>
</xf:trigger>
</td>
<td>
<xf:output ref="instance('domain')/system[@name = instance('results')/result/ServiceDefinition[index('link-repeat')]/SystemName]/NIC/@state" />
</td>
</tr>
</xf:repeat>
</tbody>
</table>
</div>
的問題似乎是這一部分:
<td>
<xf:output ref="instance('domain')/system[@name = instance('results')/result/ServiceDefinition[index('link-repeat')]/SystemName]/NIC/@state" />
</td>
有什麼不對的表達?我想獲取匹配repeat語句中當前節點的系統的狀態屬性。 然而,當我加載頁面和「results'實例包括許多項目的我得到一個JavaScript錯誤:
A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete.
Script: http://test:8080/exist/xforms/xsltforms/xsltforms.js:771*
線(在這種情況下771)總是不同。
當結果實例非常小(最多約20個元素)時,它按預期工作。
任何幫助或建議表示讚賞,我是新來的所有這一切,請耐心等待。