Franch
Franch

Reputation: 175

XML Code Analysis

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?

Upvotes: 2

Views: 1952

Answers (1)

ColinE
ColinE

Reputation: 70112

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.

Upvotes: 3

Related Questions