2012-03-08 54 views
1

我正在使用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个元素)时,它按预期工作。

任何帮助或建议表示赞赏,我是新来的所有这一切,请耐心等待。

回答

0

由于XSLTForms具有用JavaScript编写的自己的XPath引擎,因此浏览器可能会很慢地评估需要浏览大量节点的表达式,尤其是旧版本的Internet Explorer。

最近性能得到了提高,您应该尝试在sourceforge.net上使用XSLTForms的SVN存储库中的最新版本。使用id()功能可以大大缩短评估时间。

还有一个XSLTForms特定扩展,用于指示实例是否只包含只读数据。

您是否尝试过Profiler(首先按F1)以获得时间度量?