Title:
XMLParse() and XMLValidate() generate error when validating against namespace-aware schema
| View in TrackerStatus/Resolution/Reason: To Fix//
Reporter/Name(from Bugbase): A. Bakia / A. Bakia (A. Bakia)
Created: 03/09/2016
Components: Language
Versions: 2016
Failure Type:
Found In Build/Fixed In Build: Beta2_v12 /
Priority/Frequency: Minor / Few users will encounter
Locale/System: English / Win All
Vote Count: 1
Problem Description: XMLParse() and XMLValidate() generate error when validating against namespace-aware schema. There is no such error when I validate using Java-based namespace-aware code.
Steps to Reproduce: Store the attached XML and XSD file in the same directory as the following 2 CFM files.
xmlValidationTest.cfm:
<cfset validationResults=XMLValidate(expandpath('test.xml'),expandpath('test.xsd'))>
<cfdump var="#validationResults#">
xmlParseTest.cfm:
<cftry>
<cffile action="read" file="#expandpath('test.xml')#" variable="xmlstr">
<cffile action="read" file="#expandpath('test.xsd')#" variable="xsdstr">
<cfset validationResult=XMLParse(xmlstr,false,xsdstr)>
<cfdump var="#validationResult#">
<cfcatch type="any">
<cfdump var="#cfcatch#">
</cfcatch>
</cftry>
Actual Result: An error: cvc-elt.1: Cannot find the declaration of element 'BenchmarkImport'.
Expected Result: Successful error-free validation
Any Workarounds: the following Java-based code
<!--- Validate an XML document against an XSD, reading both in as file objects --->
<cfscript>
try {
/*Set up XML parser*/
documentBuilderFactoryInstance = createobject("java","javax.xml.parsers.DocumentBuilderFactory").newInstance();
/* Specify that the parser produced by this code provide support for XML namespaces. By default this value is false */
documentBuilderFactoryInstance.setNamespaceAware(true);
parser = documentBuilderFactoryInstance.newDocumentBuilder();
/* Parse an XML document into a DOM tree */
document = parser.parse(createobject("java","java.io.File").init(expandPath('test.xml')));
/* Create a SchemaFactory capable of understanding WXS schemas */
factory = createobject("java","javax.xml.validation.SchemaFactory").newInstance(createobject("java","javax.xml.XMLConstants").W3C_XML_SCHEMA_NS_URI);
/* Load a WXS schema, represented by a Schema instance */
schemaFile = createobject("java","javax.xml.transform.stream.StreamSource").init(createobject("java","java.io.File").init(expandPath('test.xsd')));
schema = factory.newSchema(schemaFile);
/* Create a Validator instance, and use it to validate an instance document */
validator = schema.newValidator();
domResult = validator.validate(createobject("java","javax.xml.transform.dom.DOMSource").init(document), createobject("java","javax.xml.transform.dom.DOMResult"));
writeoutput('Valid XML document!');
}
catch (any e) {
writedump(e);
}
</cfscript>
----------------------------- Additional Watson Details -----------------------------
Watson Bug ID: 4126462
External Customer Info:
External Company: (withheld for privacy)
External Customer Name: A. Bakia
External Customer Email: A.BAKIG@CHELLO.NL
External Test Config:
Bug File Paths:
\\sjshare.corp.adobe.com\Prereleasebugfiles\ColdFusion\12.0\Beta2_v12\4106301\xmlValidateNameSpaceError.html
\\sjshare.corp.adobe.com\Prereleasebugfiles\ColdFusion\12.0\Beta2_v12\4106301\xmlParseNameSpaceError.html
\\sjshare.corp.adobe.com\Prereleasebugfiles\ColdFusion\12.0\Beta2_v12\4106301\test.xsd
\\sjshare.corp.adobe.com\Prereleasebugfiles\ColdFusion\12.0\Beta2_v12\4106301\test.xml
Attachments:
Comments: