具有相互依赖性检查的验证层 [英] Validation Layer with interdependency checks

查看:86
本文介绍了具有相互依赖性检查的验证层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将为更多客户端打开现有的后端服务(将Web服务层添加到Web前端客户端).
当前,XML Schema用于DTO的验证,但是由于前端不在我们的控制范围内,因此我们将不得不将扩展测试(例如,相互依赖性测试)从前端层移动到新的验证层".
现在我们的问题是,例如,是否存在一个通用模式.类似于使用RELAX NG或规则引擎?要求是能够检查数据类型(这里将保留XML Schema)和相互依赖性,但是这些相互依赖性会变得非常复杂,即.它们可能涉及检查输入数据中不可用的数据(但在某些外部系统中).
因此,我们正在寻找一种模式以及一个易于实现这些模式的框架.

Existing backend services will be opened for more clients (adding a Web Service Layer to the Web-Frontend client).
Currently, XML Schema is used for validation of DTOs, but since the frontend is out of our control, we will have to move extended tests (eg. interdependency tests) from the frontend layer to a new "validation layer".
Now our question is if there exist a common pattern for this, eg. something similar to using RELAX NG or a rule engine? The requirement is to be able to check datatypes (we would stay with XML Schema here) and interdependencies, but these interdependencies can get quite complicated, ie. they might involve checks on data which is not available in the input data (but in some external system).
So we are looking for a patterns as well as a framework which makes it easy to implements the patterns.

推荐答案

Schematron 是架构要查看的语言(可能用作XSD之上的一层).

Schematron is the schema language to look at (used as a layer on top of your XSD probably).

Schematron基于使用XPath表示的约束,该约束在大多数情况下足以表达所需的内容.由于XPath可以使用用户定义的功能扩展,因此存在一定的范围,可以通过例如以下方式进行任何验证.比较来自外部数据库等的数据.

Schematron is based around constraints expressed using XPath, which in most cases is powerful enough to express what is needed. Since XPath can be extended with user-defined functions, there is scope to be able to carry out potentially any validation by e.g. comparing data from external databases etc.

(如果出于验证目的而使用文档外部的数据,一种不错的方法是将外部数据公开为XML-可能以RESTy形式提供-这样,验证约束就可以在Schematron模式中完全以XML术语表示)

(If you are drawing on data outside your document for validation purposes a nice approach is to expose that external data as XML - perhaps available in a RESTy fashion - so the validation constraints can be expressed entirely in XML terms within your Schematron schema.)

这篇关于具有相互依赖性检查的验证层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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