【问题标题】:How can i debug a xform submission?如何调试 xform 提交?
【发布时间】:2014-07-01 11:20:43
【问题描述】:

我在调试 xhtml 文件中的 xform 时遇到问题。以前它可以工作,但现在我在 xf:model 的命名空间中更改了一些内容,现在当我按下提交按钮时它什么也没做。我将举一个简单的例子,以便您更好地理解我的问题,但请记住,我正在处理一个包含 400 多行的 xhtml 文件,而且我一直在浪费时间(上周几乎 40 小时)逐行调试,反复试验以找出我的表单出了什么问题。

    <html namespaces come here>
    <head>
       <title>Example</title>
       <xf:model schema="foobar.xsd">
         <xf:instance>
            <Persons xmlns="">
               <name></name>
            </Persons>
         <xf:/instance>
       </xf:model>
       <xf:bind id=name nodeset="/Person/aluno" type="xs:string"/>
       <xf:submission id="submit" action="http://localhost:8080/exist/rest/db/apps/foo/bar.xquery" method="post"/>
    </head>
    <body>
      <h1>Type the name of the Person</h1>
      <xf:input bind="name">
       <xf:label>
                <b>Name:</b>
       </xf:label>
      </xf:input>
      <xf:submit submission="submit">
        <xf:label>SUBMIT</xf:label>
      </xf:submit>
    </body>
    </html>

好的,这是一个简单的例子(它可能有一些错误,没关系),但想象一下,每次我按 SUBMIT 时它什么也没做。 我怎样才能找到导致错误的原因?

【问题讨论】:

  • 我的意思是,有什么调试工具可以用吗?
  • 您是使用 BetterFORM 还是 XSLTForms 作为 XForms 引擎???
  • @loveMeansNothing 哈哈,这真的让我发笑:) 我确信 Alain 想知道您使用的是这两个引擎中的哪个 XForm 引擎。但我不得不说,严格来说你的答案是正确的:-)
  • @dirkk 感谢您指出这一点,我真的很累 LOL
  • @Alain Couthures 我正在使用 BetterFORM

标签: xml xhtml xquery xforms exist-db


【解决方案1】:

@loveMeansNothing 出现以下错误消息:“未知 XML 根元素:wiki:article_container”您尚未在 'html 上声明命名空间 xmlns:wiki="http://www.generic-wiki.org/Wiki" ' 元素?此外,您在提交时缺少 xforms @replace 属性,这意味着它默认为 replace="all"(遵循 XForms W3C 建议),您是否尝试在此处使用 @repalce="none" 或 @replace="instance" (取决于您要归档的内容)?

关于betterFORM @adamretter 的调试已经指出了在哪里可以找到日志以及如何启用调试栏。此外,您可以在提交中添加一个 xforms-submit-error 处理程序:

<xf:submission id="..." ...>
  <xf:action ev:event="xforms-submit-error">
    <xf:message>Submit Error! Resource-uri: <xf:output value="event('resource-uri')"/>
                Response-reason-phrase: <xf:output value="event('response-reason-phrase')"/>
    </xf:message>
  </xf:action>
</xf:submission>

我经常使用 Firebug 进行调试。

如果这一切都不能解决您的问题,最好有一个您的表单的运行示例来重现错误。

【讨论】:

  • 我已经这样做了,现在我提交时总是收到此错误:tinypic.com/r/bi1c91/8 资源是这样调用的,它具有执行权限:localhost:8080/exist/rest/db/apps/peitp14/logic/…" method="post"/>
【解决方案2】:

我终于找到了解决办法!

在调用的 xquery 上缺少一个愚蠢的斜线

      <xf:submission id="submit" action="http://localhost:8080/exist/rest/db/apps/myapp/logic/action.xquery" method="post"/>

如果看起来像这样:

let $store:=xmldb:store('db/apps/myapp/data','test.xml', $newArticle)

虽然它应该看起来像这样(见斜线):

let $store:=xmldb:store('/db/apps/myapp/data','test.xml', $newArticle)

我还创建了一个新用户,并通过exist-db Java Admin Client 将他添加到“dba”组中。之后,我在 exide 使用新的用户名凭据创建了一个新应用程序。 还在这里使用了该用户:

   let $login:=xmldb:login('/db/apps/myapp','user','password')

感谢大家的帮助:)

【讨论】:

    猜你喜欢
    • 2015-03-17
    • 2013-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-10
    • 2023-04-11
    • 2011-11-25
    • 2020-08-10
    相关资源
    最近更新 更多