XML含开头处理指令时mlcp导出redaction功能报错问题
MarkLogic MLCP导出脱敏(Redaction)遇XML处理指令报错问题
问题现象
使用MLCP导出命令的redaction(脱敏)选项时,若XML文件在版本声明后紧跟处理指令(PI),会触发以下错误:
[1.0-ml] RDT-NODE: (err:FOER0000) Unsupported node type: Only XML document or JSON document can redacted
移除XML中的处理指令行后,报错消失,导出脱敏流程正常运行。
示例文件
触发报错的原XML文件
<?xml version="1.0" encoding="UTF-8"?> <?xml-model type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron" href="../../../ml-schemas/coaching-report.form.sch"?> <?xml-model type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema" href="../../../ml-schemas/coaching-report.xsd"?> <form version="coaching-report-v1" xmlns="http://data.eic.eu/model/coaching-report"> <entry name="managementTeam"> <question> ....... </form>
可正常运行的XML文件(移除处理指令后)
<?xml version="1.0" encoding="UTF-8"?> <form version="coaching-report-v1" xmlns="http://data.eic.eu/model/coaching-report"> <entry name="managementTeam"> <question> </form>
问题验证
通过XQuery直接调用MarkLogic脱敏模块,确认问题根源在rdt:redact函数对包含处理指令的XML文档支持异常:
xquery version "1.0-ml"; import module namespace rdt = "http://marklogic.com/xdmp/redaction" at "/MarkLogic/redaction.xqy"; rdt:rule-validate("redactRules:anonymization"), rdt:redact(doc('/data/template/coaching-report-v1.xml'), "redactRules:anonymization")
执行上述代码时,包含处理指令的文档会抛出与MLCP一致的错误;移除处理指令后,代码执行正常,脱敏操作成功完成。
内容的提问来源于stack exchange,提问作者Marc Messéant
相关产品推荐
相关产品推荐

