简体   繁体   English

XForms重复-JavaScript错误

[英]XForms repeat - JavaScript error

I am using XForms to build a web application with XML-DB eXist-db as backend. 我正在使用XForms以XML-DB eXist-db作为后端来构建Web应用程序。 eXist transforms the XForms code into HTML and JavaScript. eXist将XForms代码转换为HTML和JavaScript。

First of all I got two instances: 首先,我有两个实例:

<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>

I want to build a table using xf:repeat to iterate through all the <ServiceDefinition> Elements in the 'results' instance. 我想使用xf:repeat来构建表,以迭代“结果”实例中的所有<ServiceDefinition>元素。 Every row contains a 'Status' column where I want to put the related 'state' information from the 'domain' instance. 每行都包含一个“状态”列,我要在其中放置“域”实例中的相关“状态”信息。

This is the XForms code for the table: 这是表的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>

The problem seems to be this part: 问题似乎是这部分:

<td>
  <xf:output ref="instance('domain')/system[@name = instance('results')/result/ServiceDefinition[index('link-repeat')]/SystemName]/NIC/@state" />
</td>

Is there something wrong with this expression? 这个表达式有问题吗? I want to get the state attribute of the system that matches the current node in the repeat statement. 我想获取与repeat语句中的当前节点匹配的系统的state属性。 However when I load the page and the 'results'-instance consist of many items I get a Javascript error: 但是,当我加载页面并且'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*

The line (in this case 771) always differs. 行(在这种情况下为771)始终不同。

When the result instance is very small (up to about 20 Elements) it works as expected. 当结果实例很小(最多约20个元素)时,它将按预期工作。

Any help or suggestion appreciated, I am new to all this, so please be patient. 感谢您的任何帮助或建议,我对此并不陌生,因此请耐心等待。

Because XSLTForms has its own XPath engine written in JavaScript, browsers might be slow to evaluate expressions requiring to navigate through a lot of nodes, especially old versions of Internet Explorer. 由于XSLTForms拥有自己的用JavaScript编写的XPath引擎,因此浏览器评估需要浏览许多节点(尤其是Internet Explorer的旧版本)的表达式时可能会很慢。

Performance has been improved recently and you should try with latest build in SVN repository of XSLTForms at sourceforge.net. 最近性能有所提高,您应该尝试在sourceforge.net上XSLTForms的SVN存储库中的最新构建。

Using the id() function is a possibility to heavily reduce evaluation time. 使用id()函数可能会大大减少评估时间。

There is also an XSLTForms specific extension to indicate whether an instance contains only readonly data. 还有一个XSLTForms特定的扩展,以指示实例是否仅包含只读数据。

Did you try the Profiler (press F1 first) to have time measures? 您是否尝试使用Profiler(首先按F1)进行时间测量?

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

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