• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reverse engineer XML document

Just download the schema specified by the SchemaLocation attribute in the document..

Oh the irony, how we laughed. Yea in theory that's the way, in reality it's a pointless attribute.

I find the OPs question strange; without a schema the xml can contain anything. As others have advised some tools do exist to infer a schema from a document but that's all they do..infer the schema. It doesn't mean the correct schema is inferred and often it won't be. You could equally just look at the xml document and create your own schema from scratch to match what you think it should look like..and then you'll get it wrong all on your own.

The owner / source vendor of the xml document needs to confirm the validity and content of the xml document and if they can do that then they should provide a valid schema. If this isn't possible then this sounds like a train wreck waiting to happen to me.
 
I find the OPs question strange;
I agree but I think, in case there were better options, OP wouldn't be asking such questions in the first place.

There are quite a few realistic scenarios where you get XML and get no schema with it (company went bust, proprietary protocol, politics, etc), in such case it's probably worthwhile to try and develop one of your own and perhaps improve it over time.
One of the benefits, for instance is processing with the Schema-Aware XSL Processor such as saxon - it gives nice performance boost and a lot more useful warnings and errors, when schema awareness is enabled.
 

Advertisers

Back
Top