Wednesday, June 24, 2009

a good POSR to validate against…. final thoughts on cXML PunchOut validation…

… and another email came in asking if I had a copy of a “good” cXML example I could share.

Actually, the best cXML examples are off of www.cxml.org which has a lovely link you can download imagethe files you need from.  If you always download their latest and greatest help, examples and docs at this link: http://xml.cxml.org/current/cXML.zip

Which will get you a very cool zip file that has samples for almost any kind of cXML operation you’re looking to pull off. 

image

Inside the zip is the examples directory – which is just piled all full of cXML goodies.  And in a blog or two ago I mentioned that humorously enough if you tried to validate any of those examples against the cxml.org dtd file… it would fail. 

And someone mentioned I never said why they fail other than they’re meant for very generic situations.  Which is … not entirely true.

 

It really depends on your outlook.  And if you want to see any of these files actually “validate” then you need to do one thing… change the DTD version in the DOCTYPE tag.  That’s the second line in the document and it would look like…

<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.020/cXML.dtd">
 

So in order to make any of these work… set it back to an earlier version which we know is compliant.  If for example you take the current PunchOutSetUpRequest and attempt to validate it against the DTD there’s a lot of fields which need to be implemented, and yes – you actually do have to add the appropriate Elements and Attributes under the tag to make it conform to 1.2.020 standard.  This sample to be honest is actually a 1.2.008 compliant DTD file – and to verify this simply change the validation dtd url to that version. 


<!DOCTYPE cXML SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.0008/cXML.dtd">


And you’ll get these results…






cXML Validated
Against the 1.2.008 DTD
Valid 1.2.008
cXML Validation Failed
Against the  1.2.020 DTD
Invalid 1.2.020 DTD

  


So the DTD really is the lord and master and it really does matter when it comes to validation.  It determines the rules by which the document is considered ‘good’, it covers how to handle whitespaces and escaped characters and all manner of things.  And with each DTD you have a slightly different set of rules that are applied. 


A file which validates fine against an earlier version can fail when validated against a newer set of standards.  So if you fail validation with DTD errors – try validating it against an earlier version. 

2 comments:

Anonymous said...

Interesting article about Puncout cXML.
CXML Punchout

Unknown said...

cXML PunchOut - Commerce extensible markup language application who is a protocol created by Ariba used to communicate between sessions across the internet.
Commerce Extensible Markup Language Punchout