查询生成'XDMP-CHILDNODEKIND:$ final-元素节点不能具有二进制节点子节点'错误 [英] Query generate 'XDMP-CHILDNODEKIND: $final -- element nodes cannot have binary node children' error

查看:38
本文介绍了查询生成'XDMP-CHILDNODEKIND:$ final-元素节点不能具有二进制节点子节点'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的简单查询,它从目录中读取所有文件,并将所有文件保存在$ final变量中,并保存在一个文件中.

Below is my simple query, that reads all files from a directory and holds all files in $final Variable save in one single file.

但是,运行此查询时,花了一些时间后,它提示 [1.0-ml] XDMP-CHILDNODEKIND:$ final-元素节点不能具有二进制节点子节点错误.

But when run this query, after taking some time, it prompt [1.0-ml] XDMP-CHILDNODEKIND: $final -- element nodes cannot have binary node children error.

let $input-dir :=xdmp:filesystem-directory("d:\work\may\06-05-2019\all- 
 feeds-input-output\clc\log\clc-true-ouput\")/dir:entry
let $final :=      
      for $each at $i in $input-dir
      return  
        xdmp:document-get($each/dir:pathname/text(), 
          <options xmlns="xdmp:document-get">
            <repair>full</repair>
            <encoding>UTF-8</encoding>
          </options>)
return 
  xdmp:save("D:\WORK\MAY\06-05-2019\ALL-FEEDS-INPUT-OUTPUT\CLC\LOG\COMBINE-XMLs\Combine-CLC-TRUE-INPUT.xml", 
       document{<records>{$final}</records>})

实际上,我在本地系统中有10000个小文件,我想合并为一个文件.

Actually, I have 10000 small files in the local system and I want to Merge in single file.

推荐答案

该目录可能包含二进制文档(例如PDF,图像等).当您使用 xdmp:document-get()阅读这些文档时,将获得一个 binary()节点.

The directory likely contains binary documents (i.e. PDF, images, etc). When you read those documents with xdmp:document-get(), you will get a binary() node.

如错误消息所示, binary()节点不能是XML元素的子级.

As the error message indicates, binary() nodes cannot be children of an XML element.

您的 $ final 变量将是一系列文档,其中至少一个是 binary()节点.

Your $final variable will be a sequence of documents, and at least one of them is a binary() node.

您可以排除那些 binary()节点.例如,通过将谓词过滤器添加到 xdmp:document-get():

You could exclude those binary() nodes. For instance, by adding a predicate filter to the results of the xdmp:document-get():

let $final :=      
  for $each at $i in $input-dir
  return 
    xdmp:document-get($each/dir:pathname/text(), 
      <options xmlns="xdmp:document-get">
        <repair>full</repair>
        <encoding>UTF-8</encoding>
      </options>
    )[not(. instance of binary())]

或者您可以 base64编码二进制数据,以便可以将其添加到XML:

or you could base64 encode the binary data, so that it can be added to the XML:

let $final :=      
  for $each at $i in $input-dir
  let $doc := 
    xdmp:document-get($each/dir:pathname/text(), 
      <options xmlns="xdmp:document-get">
        <repair>full</repair>
        <encoding>UTF-8</encoding>
      </options>)
  return
    if ($doc instance of binary()) 
    then xdmp:base64-encode($doc)
    else $doc

这篇关于查询生成'XDMP-CHILDNODEKIND:$ final-元素节点不能具有二进制节点子节点'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆