XML代码分析

发布于 2024-12-26 12:55:39 字数 372 浏览 2 评论 0原文

我有几个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

脱离于你 2025-01-02 12:55:39

首先,您可能应该根据架构 (XSD) 测试您的 XML 文件,我认为这是一个很好的做法。但是,您描述的规则例如:

如果节点属性“A”是“blablabla”,则节点“B”必须是
设置为值“X”

无法单独通过模式进行测试。

这是一个常见问题,因此我建议不要发明自己的解决方案,而是查看现有的解决方案,例如 Schematron 。在他们的网站上,它将该技术描述为:

一种用于对存在或不存在做出断言的语言
XML 文档中的模式。请参阅此概述了解更多信息
信息。

我已经有一段时间没有使用它了,但我确实记得它对于此类事情非常有用。

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:

If the node attribute "A" is "blablabla", the node "B" have to been
set to the value "X"

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:

A lan­guage for making as­ser­tions about the pres­ence or ab­sence of
pat­terns in XML doc­u­ments. See this overview for more
in­for­ma­tion.

It's been a while since I used it, but I do recall it being quite good for this sort of thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文