【问题标题】:Watson Dialog service error invalid schema for xml fileWatson Dialog 服务错误,xml 文件的架构无效
【发布时间】:2016-02-03 21:49:26
【问题描述】:

我正在使用 node.js 来使用 Watson Dialog 系统。我正在使用一个函数来创建一个新对话框,但是在代码的某个地方我遇到了一个与读取的 xml 文件相关的奇怪错误

{ code: 400,
  error: 'Failed to import file. Possibly due to corrupt or invalid file or system error. - java.lang.IllegalStateException: reader must be on a START_ELEMENT event, not a -1 event',
  conversionLog: 'WARN: No valid xsd schema specified in XML header. Assuming version="WatsonDialogDocument_1.1".\n' }

我正在使用可作为对话系统测试示例的比萨对话 xml,因此我认为问题不在于文件无效。这是我用来创建对话框的代码。

  var params = {
  name: req.body.username,
  file: fs.createReadStream(__dirname+'/public/dialogs/users/'+req.body.username+'/'+req.body.username+'.xml')
  };

  dialog_service.createDialog(params, function(err, dialog) {
  if (err)
    console.log(err)
  else
    console.log(dialog);
  });

我的 WatsonDialogDocument_1.0.xsd 文档与 xml 对话文件位于同一文件夹中。在对话框的 xml 文件中,您也可以找到这个

<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

【问题讨论】:

    标签: xml node.js xsd ibm-watson watson-dialog


    【解决方案1】:

    尝试将版本升级到 WatsonDialogDocument_1.1.xsd。 您还应该尝试首先从 REST 客户端发布您的 xml。 cURL 或休息控制台。只是为了确保问题出在 xml 而不是代码中。

    顺便说一句, 您不需要 XSD 文件来执行 POST。

    &lt;dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.1.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;

    【讨论】:

    • 我想用1.1版本但是不知道去哪里找。
    • 我只是通过 POST 发送 xml 的名称。 xml文件被一个函数预先复制到这个路径/public/dialogs/users/'+req.body.username+'/'+req.body.username+'.xml,然后由createReadStream函数读取
    • 你不需要xsd来发布对话,所以你可以使用1.1。请检查您是否可以通过不同的 REST 客户端发布您的代码创建的 xml。例如:curl -X POST -F "file=@/yourpath/dialog.xml" -F "name=whatever" gateway.watsonplatform.net/dialog/api/v1/dialogs -u "username:password"
    • 对不起,我不太确定如何使用 curl。当我运行时,我得到了这个。 curl:没有指定 URL!
    • 我尝试了其他方法并且成功了。我想使用比萨 xml 作为为多个用户创建对话框的模板。所以我的程序将 xml 文件复制到用户文件夹,然后尝试使用这个复制的文件创建对话框。我尝试使用模板文件初始化对话框而不先复制并且它有效。似乎复制过程可能太慢了,当它尝试创建对话框时,文件可能还没有正确复制??
    猜你喜欢
    • 2016-11-14
    • 2016-11-07
    • 2015-12-21
    • 2013-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多