Support Questions

Find answers, ask questions, and share your expertise

How to get the reason for invalid XML

Rising Star

When using the ValidateXML processor with an XSD, how do I capture the reason for the invalid XML so I can troubleshoot instances when the incoming XML is invalid?  

 

Unfortunately I don't have access to a validation tool in the environment where NiFi is running so I need the feedback from the ValidateXML processor.

 

I appreciate the help.    

1 ACCEPTED SOLUTION

Super Collaborator

In this case I would suggest you write custom code through ExecuteScript processor to see if you can retrieve such error message. Not sure what else you can do. sorry

View solution in original post

6 REPLIES 6

Super Collaborator

The ValidateXML processor will write the error to the attribute "validatexml.invalid.error". Check for that attribute when the flowfile is directed to the invalid relationship. Hope that helps

Rising Star

All that attribute reports is "Validation failed".  I need to know why it failed and at what line number in the flow file it failed.  Is it possible to get this information?

Super Collaborator

In this case I would suggest you write custom code through ExecuteScript processor to see if you can retrieve such error message. Not sure what else you can do. sorry

Rising Star

OK, thank you for verifying this for me.

New Contributor

Hi @ChuckE using NiFi 1.15.2 seems to add the error detail in the "validatexml.invalid.error" attribute.
For example --> "cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type 'HotelCode"

This seems to be an issue starting from NiFi 1.16.3, maybe a bug?
You can use NiFi 1.15.2 or custom code as @SAMSAL suggested.

Rising Star

That would be nice, but unfortunately v.1.16.x  doesn't incorporate this feature and all you get is a generic message: "Validation Failed".  In the end I just resorted to downloading the problem flowfile from the queue, and then used xmllint to run a validation, which gave me the answer instantly.  But it would be really nice if the developers put the error message back into the "validatexml.invalid.error" attribute in v.1.16.x