XML代码分析
我有几个 xml 文件,它们是在 ETL (Informatica) 上实现的流程的源代码。
我需要构建一个解决方案来分析这些 XML 并生成有关它的报告。 目的是检查自制的开发规范是否得到尊重。
我不关心 DTD 或 XSD 问题中的 XML 验证(顺便说一句,XML 文件是有效的并且可以解析),但我需要构建几个规则,例如:
-此节点需要将此属性设置为 false
-如果节点属性“A”是“blablabla”,则节点“B”必须设置为值“X”
-等等...
我认为 XSLT 或 XQuery 可能是一个很好的解决方案,以报告作为输出,但是有谁知道是否有现成的代码分析工具(开源或免费软件)能够使用自制规则检查 XML 吗?
I had several xml files wich are source code for flow implemented on an ETL (Informatica).
I need to build a solution to analyse thoses XML and generate report about it.
The goal is to check if the home made development norms had been respected.
I don't care about XML validation in the DTD or XSD matter (by the way, the XML files are valid and could be parsed), but I need to build several rules like :
-This node need to have this attribute to false
-If the node attribute "A" is "blablabla", the node "B" have to been set to the value "X"
-etc...
I think XSLT or XQuery could be a good solution, with a report as output, but does anyone know if there is existing code analysis tool (open source or freeware) able to check XML with home made rules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您可能应该根据架构 (XSD) 测试您的 XML 文件,我认为这是一个很好的做法。但是,您描述的规则例如:
无法单独通过模式进行测试。
这是一个常见问题,因此我建议不要发明自己的解决方案,而是查看现有的解决方案,例如 Schematron 。在他们的网站上,它将该技术描述为:
我已经有一段时间没有使用它了,但我确实记得它对于此类事情非常有用。
Firstly, you probably should be testing your XML files against a schema (XSD), I would consider this to be good practice. However, the rules you describe, sucgh as:
cannot be tested by schema alone.
This is a common problem, so rather than inventing your own solution, I would recommend looking at existing solutions such as Schematron. From their website, it describes the technology as:
It's been a while since I used it, but I do recall it being quite good for this sort of thing.