IBM®
Skip to main content
    Country/region [select]      Terms of use
 
 
    
     Home      Products      Services & solutions      Support & downloads      My account     
 
developerworks > My developerWorks >  Dashboard > Bobby Woolf: WebSphere SOA and J2EE in Practice > ... > WebSphere Application Server > Validating XML in WAS
developerWorks
Log In   View a printable version of the current page.
Overview Connect Spaces Forums Wikis
Validating XML in WAS
Added by bwoolf, last edited by bwoolf on Sep 07, 2006  (view change)
Labels: 
(None)

Validating XML in WAS

A question we get sometimes is: How can a WAS app validate an incoming XML document?

Many (most?) XML parsers are validating parsers, meaning that it can verify that the XML document it's parsing conforms to the DTD or schema it's supposed to--that is, the document is valid. In most (all?) validating parsers, the validation is a configuration setting that can be enabled or disabled. It's disabled by default because validation is expensive and really hurts the performance of the parser. But you can turn it on when you need it and are willing to pay the performance cost.

The XML parser in WAS is not a validating parser, so there is no way to turn validation on. Why? Because validation is really expensive, and what hurts the performance of the parser in WAS hurts the performance of WAS in general and thus of all of the apps running in WAS. That's bad. WAS is a very expensive license, running on expensive hardware; too much so to dedicate much of its capacity to the relatively mundane but resource intensive task of validating XML. We could provide a validating parser, but then document that you should never turn on validation, then get performance complaints from customers who did so anyway; instead, we just use a non-validating parser.

So what are you to do? Your WAS app has an XML document coming in, you don't necessarily trust the sender to have created the doc properly, so you want to validate it before your app wastes its time trying to process data that even the XML schema could have told you isn't valid. What do you do?

You need to put a validating parser in front of WAS, between the sender and WAS. Let that validator bog down its resources validating the XML so that WAS doesn't have to. A very good example of such a specialized XML validator is the DataPower XA35.

Likewise, WAS can run XSL transforms, but that's not a real good use of WAS resources either. Rather, if you have a DataPower box available, use it to run XSLT so that WAS doesn't have to.

So, don't try to have WAS validate or transform the XML. Run the XML through the XA35 to validate and/or transform it, then run the known-to-be-valid XML with the schema your app expects into WAS to parse and process the data.


 
    About IBM Privacy Contact