4

Looking for a way we can do checks on XML files, beyond just schema validation. Have found a few references to Schematron which looks interesting, but struggling to see how we can piece this all toegether:

Problem Background

We're dealing with Oracle OSB which just generates a whole bunch of XML files. We also produce Soap-UI test suites for integration testing.

We've just started formalising our coding standards and dev guidelines, things that give us a guide when performing code reviews. However a lot of these checks really feel they could be automated. A lot like how checkstyle can do checks in our java code.

For instance, in our Soap-UI tests, we want to make sure every soap request has assertions for Schema Compliance and Soap Response. This 'check' could be written as a pretty simple xpath.

Similar checks in our OSB produced XMLs, e.g. making sure variables conform to camelCase naming, that resource paths are not referring to files outside of the project, that top level error handling is present.

Ideal Solution

We've got our builds running in maven, and the soap-ui tests are spitting out surefire formatted reports. We use jenkins as our CI server, and this is able to pick up these surefire reports so we can easily view test results and see why a build is failing.

We'd like to find something that could perform these checks for us, and have them report cleanly in jenkins.

The best I can figure out so far:

  • Have maven run ant task which runs schematron checks
  • Find a way to tranform schematron output into surefire output
  • Modify jenkins maven-runner to pick up the surefire reports produced

But feels like I'm getting stuck down the rabbit hole here. If this is the correct way to go about this, I would think someone else has already addressed this, but struggling to find anything useful about integrating schematron with CI tools or maven.

Is schematron worth investigating?

Is there other tools that integrate more closely with our existing setup that would be better suited?

Nathan
  • 51
  • 5

2 Answers2

1

You might try to use XmlUnit for such purposes.

You would write your checks in form of JUnit tests in that scenario. Simple XPath based checks are easily performed with the help of XmlUnit assertion methods such as assertXpathExists, assertXpathsEqual etc.

More complex checks might be implemented using a custom NodeTester.

Gunnar
  • 18,095
  • 1
  • 53
  • 73
0

some Python code can help, for a simple working example of Checkstyle with OSB see:

http://www.javamonamour.org/2013/07/lintcheckstyle-for-osb.html

I have used Schematron in the past, it's just not flexible enough.

Pierluigi Vernetto
  • 1,954
  • 1
  • 25
  • 27