I need some guidance with a problem that requires validating XML against a very large XSD file.

I am making use of the CSTA XML API (without SOAP). The XSD's for the messages seems to be a very intricate set of files, including each other. All XSD's are "consolidated" into a large file csta.xsd (http://www.ecma-international.org/standards/ecma-323/csta/ed3/csta.xsd), some 250 odd XSD files.

Using erlsom:compile_xsd_file/1 takes about 3 - 4 minutes to process the main XSD file on my (lower end of a medium spec'd) notebook (2 GHz Quad Core, 4 Gb RAM). So my idea was to compile the XSD into the Erlang model and write the result into a function returning the model. This function is then saved to a file. This can be done once during the build process. The problem is that my notebook crashes when it starts writing the result to file (running out of memory). This leads me to think that I am obviously not following the the best way of doing this.

The problem is further complicated by the fact that I am using the Avaya specific CSTA API. Each XSD for a single message imports the entire csta.xsd. I can work out a plan around this once I have the basics right.

Please guide me and tell me the right way of handling this type of scenario.

  • 2
    This sounds like an X Y problem. I can think of several possible optimizations. Do you really need all of the XSD's? Do you really need every detail in the XSD's you are using? Do you really need the XSD's at all? – Robert Harvey Sep 21 '16 at 14:10

If the XSD is too large, you will not be able to validate it. Your best option is not to use the XSD at all, but just load the XML into a DOM structure. If the document is valid and well formed it will load, otherwise it will fail. Keep in mind no validation will take.

Once loaded the only thing you have is Xml, so you will have to manually query and manipulate the document, elements, attributes, nodes etc. Be defensive when querying since no validation has taken place.

You could try and create a domain model from the Xml, but it will probably end up with 100s of classes with 1000s of properties if the XSD is as large and complex as indicated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.