Orbeon 自动完成 - 序言中不允许出现内容

发布于 2024-12-08 18:47:26 字数 10306 浏览 0 评论 0原文

我正在尝试将动态模式下的自动完成组件添加到使用 Orbeon Form Builder(版本 Orbeon Forms 3.9.0+.stable.201109261742 PE)创建的表单中。

下面的 xml 是一个简单的测试表单,具有自动完成功能,可从公共 Web 服务(当前使用静态请求正文)检索数据。 自动完成第一次加载数据时效果很好:项目显示在列表中。但第二次,当我输入另一个字符来缩小搜索结果范围时,或者当我从列表中选择一个项目时,我收到错误消息“序言中不允许内容”。

如果我忽略该错误并继续,错误将更改为“获得意外的请求序列号”。

我不明白为什么它只在第一次起作用,因为由于静态请求正文,Web 服务返回的数据始终相同。

下面您可以找到测试表单的完整 xml。

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:saxon="http://saxon.sf.net/"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:exforms="http://www.exforms.org/exf/1-0"
            xmlns:sql="http://orbeon.org/oxf/xml/sql"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <xhtml:head>
              <xhtml:title>Test form</xhtml:title>
              <xforms:model id="fr-form-model">
                     <xforms:instance id="fr-form-instance">
                            <form>
                                   <section-1>
                                          <codeSearch/>
                                   </section-1>
                            </form>
                     </xforms:instance>
                     <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
                            <xforms:bind id="section-1-bind" nodeset="section-1">
                                   <xforms:bind id="codeSearch-bind" nodeset="codeSearch" name="codeSearch" type="xforms:string"/>
                            </xforms:bind>
                     </xforms:bind>
                     <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
                            <metadata>
                                   <application-name>IRISbox</application-name>
                                   <form-name>Test</form-name>
                                   <title xml:lang="fr">Test form</title>
                                   <description xml:lang="fr"/>
                                   <author/>
                                   <logo mediatype="" filename="" size=""/>
                            </metadata>
                     </xforms:instance>
                     <xforms:instance id="fr-form-attachments">
                            <attachments>
                                   <css mediatype="text/css" filename="" size=""/>
                                   <pdf mediatype="application/pdf" filename="" size=""/>
                            </attachments>
                     </xforms:instance>
                     <xforms:instance id="fr-form-resources" xxforms:readonly="false">
                            <resources>
                                   <resource xml:lang="fr">
                                          <codeSearch>
                                                 <label>Cities</label>
                                                 <hint/>
                                                 <help/>
                                                 <alert/>
                                          </codeSearch>
                                          <section-1>
                                                 <label>Test</label>
                                                 <help/>
                                          </section-1>
                                   </resource>
                            </resources>
                     </xforms:instance>
                     <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
                            <request/>
                     </xforms:instance>
                     <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
                            <response/>
                     </xforms:instance>


            <!-- Search Cities by Name HTTP service -->
            <xforms:instance id="searchCitiesByName-instance" class="fr-service"
                                         xxforms:exclude-result-prefixes="#all">
                               <body>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.restfulwebservices.net/ServiceContracts/2008/01"&gt;
                   &lt;soapenv:Header/&gt;
                   &lt;soapenv:Body&gt;
                      &lt;ns:GetCitiesByCountry&gt;
                         &lt;ns:Country&gt;USA&lt;/ns:Country&gt;
                      &lt;/ns:GetCitiesByCountry&gt;
                   &lt;/soapenv:Body&gt;
                &lt;/soapenv:Envelope&gt;</body>
            </xforms:instance>
            <xforms:submission id="searchCitiesByName-submission" class="fr-service"
                                       ref="instance('fr-service-request-instance')"
                                       resource="http://www.restfulwebservices.net/wcf/WeatherForecastService.svc"
                                       method="post"
                                       serialization="application/xml"
                                       mediatype="application/soap+xml; action=GetCitiesByCountry"
                                       replace="instance"
                                       instance="searchCitiesByName-instance"/>

                    <xforms:action ev:event="xforms-submit" ev:observer="searchCitiesByName-submission">
                           <xxforms:variable name="request-instance-name" select="'searchCitiesByName-instance'"
                                          as="xs:string"/>
                           <xforms:insert nodeset="instance('fr-service-request-instance')"
                                       origin="saxon:parse(instance($request-instance-name))"/>
            </xforms:action>

        </xforms:model>
       </xhtml:head>
       <xhtml:body>
              <fr:view>
                     <xforms:label ref="instance('fr-form-metadata')/title"/>
                     <fr:body>
                            <fr:section id="section-1-section" bind="section-1-bind">
                                   <xforms:label ref="$form-resources/section-1/label"/>
                                   <xforms:help ref="$form-resources/section-1/help"/>
                                   <fr:grid columns="1">
                                          <xhtml:tr>
                                                 <xhtml:td>

                                    <fr:autocomplete

                                        id="codeSearch" 
                                        bind="codeSearch-bind"
                                        dynamic-itemset="true"
                                        max-results-displayed="50">

                                        <xforms:label ref="$form-resources/codeSearch/label"/>

                                        <!-- React to user searching -->
                                        <xforms:action ev:event="fr-search-changed">
                                            <xxforms:variable name="search-value" select="event('fr-search-value')"/>
                                            <xxforms:variable name="make-suggestion" select="string-length($search-value) &gt;= 2"/>

                                            <xforms:action if="$make-suggestion">
                                                <xforms:setvalue ref="instance('code-search-instance')/searchFor" value="$search-value"/>
                                                <xforms:send submission="searchCitiesByName-submission"/>
                                            </xforms:action>

                                            <xforms:action if="not($make-suggestion)">
                                                <!-- Delete itemset -->
                                                <xforms:delete nodeset="instance('searchCitiesByName-instance')//*:GetCitiesByCountryResult/*:string"/>
                                            </xforms:action>
                                        </xforms:action>

                                        <xforms:itemset nodeset="instance('searchCitiesByName-instance')//*:GetCitiesByCountryResult/*:string">
                                            <xforms:label ref="text()"/>
                                            <xforms:value ref="text()"/>
                                        </xforms:itemset>
                                    </fr:autocomplete>

                                                 </xhtml:td>
                                          </xhtml:tr>
                                          <xhtml:tr>
                                                 <xhtml:td>
                                                        <widget:xforms-instance-inspector xmlns:widget="http://orbeon.org/oxf/xml/widget" id="orbeon-xforms-inspector"/>
                                                 </xhtml:td>
                                          </xhtml:tr>
                                   </fr:grid>
                            </fr:section>
                     </fr:body>
              </fr:view>
       </xhtml:body>
</xhtml:html>

任何帮助表示赞赏。

I'm trying to add an autocomplete component in dynamic mode to a form created with the Orbeon Form Builder (version Orbeon Forms 3.9.0+.stable.201109261742 PE).

The xml below is a simple test form with the autocomplete that retrieves the data from a public webservice (currently with a static request body).
The first time the autocomplete loads the data it works just fine: the items are presented in a list. But the second time, when I type another character to narrow down the search results, or when I select an item from the list, I get the error message "Content is not allowed in prolog".

If I ignore the error and continue anyway, the error changes to "Got unexpected request sequence number".

I don't understand why it only works the first time since the data returned by the web service is always the same because of the static request body.

Below you find the complete xml of the test form.

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xxi="http://orbeon.org/oxf/xml/xinclude"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:saxon="http://saxon.sf.net/"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:exforms="http://www.exforms.org/exf/1-0"
            xmlns:sql="http://orbeon.org/oxf/xml/sql"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <xhtml:head>
              <xhtml:title>Test form</xhtml:title>
              <xforms:model id="fr-form-model">
                     <xforms:instance id="fr-form-instance">
                            <form>
                                   <section-1>
                                          <codeSearch/>
                                   </section-1>
                            </form>
                     </xforms:instance>
                     <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
                            <xforms:bind id="section-1-bind" nodeset="section-1">
                                   <xforms:bind id="codeSearch-bind" nodeset="codeSearch" name="codeSearch" type="xforms:string"/>
                            </xforms:bind>
                     </xforms:bind>
                     <xforms:instance id="fr-form-metadata" xxforms:readonly="true">
                            <metadata>
                                   <application-name>IRISbox</application-name>
                                   <form-name>Test</form-name>
                                   <title xml:lang="fr">Test form</title>
                                   <description xml:lang="fr"/>
                                   <author/>
                                   <logo mediatype="" filename="" size=""/>
                            </metadata>
                     </xforms:instance>
                     <xforms:instance id="fr-form-attachments">
                            <attachments>
                                   <css mediatype="text/css" filename="" size=""/>
                                   <pdf mediatype="application/pdf" filename="" size=""/>
                            </attachments>
                     </xforms:instance>
                     <xforms:instance id="fr-form-resources" xxforms:readonly="false">
                            <resources>
                                   <resource xml:lang="fr">
                                          <codeSearch>
                                                 <label>Cities</label>
                                                 <hint/>
                                                 <help/>
                                                 <alert/>
                                          </codeSearch>
                                          <section-1>
                                                 <label>Test</label>
                                                 <help/>
                                          </section-1>
                                   </resource>
                            </resources>
                     </xforms:instance>
                     <xforms:instance id="fr-service-request-instance" xxforms:exclude-result-prefixes="#all">
                            <request/>
                     </xforms:instance>
                     <xforms:instance id="fr-service-response-instance" xxforms:exclude-result-prefixes="#all">
                            <response/>
                     </xforms:instance>


            <!-- Search Cities by Name HTTP service -->
            <xforms:instance id="searchCitiesByName-instance" class="fr-service"
                                         xxforms:exclude-result-prefixes="#all">
                               <body><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.restfulwebservices.net/ServiceContracts/2008/01">
                   <soapenv:Header/>
                   <soapenv:Body>
                      <ns:GetCitiesByCountry>
                         <ns:Country>USA</ns:Country>
                      </ns:GetCitiesByCountry>
                   </soapenv:Body>
                </soapenv:Envelope></body>
            </xforms:instance>
            <xforms:submission id="searchCitiesByName-submission" class="fr-service"
                                       ref="instance('fr-service-request-instance')"
                                       resource="http://www.restfulwebservices.net/wcf/WeatherForecastService.svc"
                                       method="post"
                                       serialization="application/xml"
                                       mediatype="application/soap+xml; action=GetCitiesByCountry"
                                       replace="instance"
                                       instance="searchCitiesByName-instance"/>

                    <xforms:action ev:event="xforms-submit" ev:observer="searchCitiesByName-submission">
                           <xxforms:variable name="request-instance-name" select="'searchCitiesByName-instance'"
                                          as="xs:string"/>
                           <xforms:insert nodeset="instance('fr-service-request-instance')"
                                       origin="saxon:parse(instance($request-instance-name))"/>
            </xforms:action>

        </xforms:model>
       </xhtml:head>
       <xhtml:body>
              <fr:view>
                     <xforms:label ref="instance('fr-form-metadata')/title"/>
                     <fr:body>
                            <fr:section id="section-1-section" bind="section-1-bind">
                                   <xforms:label ref="$form-resources/section-1/label"/>
                                   <xforms:help ref="$form-resources/section-1/help"/>
                                   <fr:grid columns="1">
                                          <xhtml:tr>
                                                 <xhtml:td>

                                    <fr:autocomplete

                                        id="codeSearch" 
                                        bind="codeSearch-bind"
                                        dynamic-itemset="true"
                                        max-results-displayed="50">

                                        <xforms:label ref="$form-resources/codeSearch/label"/>

                                        <!-- React to user searching -->
                                        <xforms:action ev:event="fr-search-changed">
                                            <xxforms:variable name="search-value" select="event('fr-search-value')"/>
                                            <xxforms:variable name="make-suggestion" select="string-length($search-value) >= 2"/>

                                            <xforms:action if="$make-suggestion">
                                                <xforms:setvalue ref="instance('code-search-instance')/searchFor" value="$search-value"/>
                                                <xforms:send submission="searchCitiesByName-submission"/>
                                            </xforms:action>

                                            <xforms:action if="not($make-suggestion)">
                                                <!-- Delete itemset -->
                                                <xforms:delete nodeset="instance('searchCitiesByName-instance')//*:GetCitiesByCountryResult/*:string"/>
                                            </xforms:action>
                                        </xforms:action>

                                        <xforms:itemset nodeset="instance('searchCitiesByName-instance')//*:GetCitiesByCountryResult/*:string">
                                            <xforms:label ref="text()"/>
                                            <xforms:value ref="text()"/>
                                        </xforms:itemset>
                                    </fr:autocomplete>

                                                 </xhtml:td>
                                          </xhtml:tr>
                                          <xhtml:tr>
                                                 <xhtml:td>
                                                        <widget:xforms-instance-inspector xmlns:widget="http://orbeon.org/oxf/xml/widget" id="orbeon-xforms-inspector"/>
                                                 </xhtml:td>
                                          </xhtml:tr>
                                   </fr:grid>
                            </fr:section>
                     </fr:body>
              </fr:view>
       </xhtml:body>
</xhtml:html>

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文