简体   繁体   English

处理 Marklogic Xquery 中的 TDE 错误

[英]Handle TDE errors in Marklogic Xquery

I have created templates for documents present in my ML content database without <invalid-values>ignore</invalid-values> .我已经为我的 ML 内容数据库中存在的文档创建了模板,但没有<invalid-values>ignore</invalid-values> So, my code throws TDE-INDEX error when there is an invalid row value during create / update of the document.因此,当在文档的创建/更新期间存在无效行值时,我的代码会引发 TDE-INDEX 错误。

TDE-INDEX: xdmp:eval("xquery version "1.0-ml"; import module namesp...", (), ****...) -- Error applying template /template.xml to document /workid.xml: TDE-EVALFAILED: Eval for Column subject_name='$subject[@code eq $subject_code]/text()' returns multiple values (only one is expected) TDE-INDEX: xdmp:eval("xquery version "1.0-ml"; import module namesp...", (), ****...) -- 将模板 /template.xml 应用到文档 /workid 时出错。 xml: TDE-EVALFAILED: Eval for Column subject_name='$subject[@code eq $subject_code]/text()' 返回多个值(预计只有一个)

Now I have a requirement where I need to track this error in the ErrorLog.txt file and continue the document insertion.现在我有一个需求,我需要在 ErrorLog.txt 文件中跟踪此错误并继续插入文档。

From the Marklogic documents regarding TDE, I could see this can be handled in two ways.从有关 TDE 的 Marklogic 文档中,我可以看到这可以通过两种方式处理。

  1. Setting <invalid-values>ignore</invalid-values> and we cannot log the error and it would continue the operation设置<invalid-values>ignore</invalid-values>我们无法记录错误,它将继续操作

  2. Without the option, the error would be thrown and the processing would be stopped.如果没有该选项,将引发错误并停止处理。

Now there are two questions for which I'm looking answers for:现在有两个问题我正在寻找答案:

  1. Is it possible to catch the TDE errors using try/catch expression?是否可以使用 try/catch 表达式捕获 TDE 错误?

  2. Is it possible to log the TDE error and allow document insert/update operation?是否可以记录 TDE 错误并允许文档插入/更新操作?

For all of our mission critical documents using TDE, we actually first do an explicit call to validate the document against an XSD.对于我们所有使用 TDE 的关键任务文档,我们实际上首先进行显式调用以根据 XSD 验证文档。 Then we know in advance if it would error on a strict TDE template.然后我们提前知道它是否会在严格的 TDE 模板上出错。 For many items, we actually generate the TDE and schema from a DSL guaranteeing that they agree.对于许多项目,我们实际上从 DSL 生成 TDE 和模式,以保证它们一致。

By doing the validate in advance, one could then use business logic to log errors and trigger the TDE index or not by some switching mechanism that works with TDE:通过预先进行验证,然后可以使用业务逻辑记录错误并通过与 TDE 一起使用的某种切换机制来触发或不触发 TDE 索引:

  • collection收藏
  • directory目录
  • context语境

One trick we often use is to embed hints to s template or sub template in context logic.我们经常使用的一种技巧是将提示嵌入到上下文逻辑中的模板或子模板中。 For instance, you could store a Boolean about validation success in an element or collection and use a context like /some/path[fancy condition related to node -collection or element ]例如,您可以将有关验证成功的 Boolean 存储在元素或集合中,并使用/some/path[fancy condition related to node -collection or element ]类的上下文

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM