17 January 2011

CFMX 7 has builtin xsd validation using the xmlParse function. What about CFMX 6.1. There is a very neat udf on cflib.org site called xsdValidate.

Here is an example using this udf in cfmx 6.1.

<cfset err = structNew()> <cfset xmlUri = "[file:///c:/test/bad.xml](file:///c:/test/bad.xml)"> <cfset xsdUri = "[file:///c:/test/test.xsd](file:///c:/test/test.xsd)"> </font> Valid: #xsdValidate(xmlUri, xsdUri, "", err)#
</cfoutput> <cfdump var="#err#" label="Information about the error, if any"></div> This udf requires the Xerces XML parser. It works by calling the underlying Java classes to validate the xml against the xsd file. Kudos to Sameul Neff who wrote this udf.

blog comments powered by Disqus