Validate XML against XSD in pure ABAP Validate XML against XSD in pure ABAP xml xml

Validate XML against XSD in pure ABAP


Use this this report for XSD-related validation in ABAP:RPCXMLK0_VALIDATE
It can be launched programmatically as well.


Incase anybody comes by...

As far as I've been able to find while searching around the internet so far, there is no native way in ABAP to validate an XML document against a XSD schema. The best option you have is a DTD.

My code samples aren't complete so copy and pasting won't work, but basically what I've done was save the XSD schema on the application server and the XML file in the temporary directory. I call the java program and pass it the XML and XSD file as arguments.

enter image description here

Here is the java code

Java XSD Validator

From ABAP, you can call this command and pass the file you saved with OPEN DATASET. Here is a code sample:

ABAP Validator and OS Command

It works, but it's rather slow. I'm on a computer with rather modest hardware compared to a live server, but it takes about 350ms per check with a small XSD and small XML.

I'm not sure if running it as a service or RFC will improve performance, but if you want it's worth a shot.