繁体   English   中英

XForms重复-JavaScript错误

[英]XForms repeat - JavaScript error

我正在使用XForms以XML-DB eXist-db作为后端来构建Web应用程序。 eXist将XForms代码转换为HTML和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语句中的当前节点匹配的系统的state属性。 但是,当我加载页面并且'results'-instance由许多项目组成时,我遇到了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个元素)时,它将按预期工作。

感谢您的任何帮助或建议,我对此并不陌生,因此请耐心等待。

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

最近性能有所提高,您应该尝试在sourceforge.net上XSLTForms的SVN存储库中的最新构建。

使用id()函数可能会大大减少评估时间。

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

您是否尝试使用Profiler(首先按F1)进行时间测量?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM