使用rest api针对xsd验证文档:marklogic [英] validate document against xsd using rest api : marklogic

查看:88
本文介绍了使用rest api针对xsd验证文档:marklogic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用文档rest api的PUT方法插入文档,但是如果要使用架构,则我想在导入 xml 文档之前对其进行验证,如果失败,我必须将其报告回来.我如何在Marklogic中使用与xquery中的xdmp:validate()类似的rest api实现此目标?

I am using PUT method of document rest api for inserting document but I want to validate xml document before ingestion using schema if it fails I have to report it back. How can I achieve this within Marklogic using rest api similiar to xdmp:validate() in xquery ?

我遇到了诸如预提交触发器,创建休止转换等方法.寻找您的输入.

I have come across approach like pre-commit triggers, creating rest transformation etc..looking for your inputs.

推荐答案

预提交触发器更难以配置,并且会占用更多开销.我去休息一下.那可能很简单:

Pre-commit triggers are more difficult to configure, and take more overhead. I'd go for a rest transform. That could be as simple as:

xquery version "1.0-ml";

module namespace trans = "http://marklogic.com/rest-api/transform/validate";

declare function trans:transform(
  $context as map:map,
  $params as map:map,
  $content as document-node()
) as document-node()
{
  let $validate := validate strict { $content }
  return $content
};

注意:请以转换名称"validate"上传此文件,因为转换名称必须与其名称空间匹配.

Note: upload this with transform name 'validate', as transform name must match its namespace.

HTH!

这篇关于使用rest api针对xsd验证文档:marklogic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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