0

I have an XML and XSD file. I am using Apache NiFi to convert XML to JSON. However, it is nested in many levels and hence I want to validate if the conversion is fine. I want to validate the same using XSD in Apache NiFi. I will not be able to share the company sensitive information. Is there any processor or script that I can use? there is an option of writing Python script in a processor called ExecuteScript.


Thanks in advance

1 Answers1

0

There are two parts to your question.

  1. Can JSON be validated via XSD?
  2. Does nifi have a processor that validates JSON via XSD?

The first part already is answered here: Validate JSON against XML Schema (XSD)

Now for the second part, depending on the solution you end up going with, neither one is implemented in a nifi processor, and attempting to use the ExecuteScript will not work for you because these require use of imported non-native modules. Instead you would need to create your own custom processor with java and import that into nifi which would solve your problem. This is all a bit labor intensive.

Alternatively, you could try a reverse conversion back to XML into an attribute and then validate that attribute content against the original XSD. This is a method I use a lot when writing unit tests. I haven't personally tried this in nifi, but it sounds like it would be possible and would likely be the least complicated solution.

Anthony Davis
  • 31
  • 1
  • 3