tracker issue : CF-4126462

select a category, or use search below
(searches all categories and all time range)
Title:

XMLParse() and XMLValidate() generate error when validating against namespace-aware schema

| View in Tracker

Status/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:

Adding BUG AUDIT TRAIL ********action: updated fieldName: Fix By Milestone newValue: Alpha oldValue: Blank oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Found in Phase newValue: Post Release oldValue: Blank oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Priority newValue: 2 oldValue: 0 oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Status newValue: ToFix oldValue: Unverified oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Owner newValue: awdhesh oldValue: aksriniv oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Severity newValue: 2 oldValue: 3 oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Fix By Product Milestone newValue: Alpha oldValue: Blank oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Reason newValue: BugVerified oldValue: Blank oprid: aksriniv recordName: RQ_DEFECT timpestamp: 2016-01-29 07:28:25.0 action: updated fieldName: Owner newValue: aksriniv oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-01-28 04:58:17.0 action: updated fieldName: QE Assigned newValue: aksriniv oldValue: inoel oprid: vmannebo recordName: RQ_DEFECT timpestamp: 2016-01-28 04:58:17.0
Comment by CFwatson U.
4060 | March 09, 2016 02:11:54 AM GMT
Added By: PreRelease User User Name:A. Bakia Note Added: Entered Bug. Date Added :2016-01-12 11:53:51.0
Comment by CFwatson U.
4061 | March 09, 2016 02:11:56 AM GMT
I can reproduce this exact same issue. We have a government customer with a list of XSD files that are all related by one XSD with multiple entries like this: <xsd:include schemaLocation="another.XSD"/> But we get a 500 error every time. The XSD files are all in the same directory, Here are the log files: "Error","XNIO-1 task-24","01/24/20","09:04:45","","'' The specific sequence of files included or processed is: C:\temp\validateXMLTest.cfm'' " java.lang.StackOverflowError at java.security.AccessController.doPrivileged(Native Method) at org.apache.xerces.impl.XMLEntityManager.getUserDir(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.expandSystemIdStrictOff(Unknown Source) at org.apache.xerces.impl.XMLEntityManager.expandSystemId(Unknown Source) at org.apache.xerces.impl.xs.XMLSchemaLoader.resolveDocument(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.resolveSchemaSource(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) at org.apache.xerces.impl.xs.traversers.XSDHandler.constructTrees(Unknown Source) ...and this repeats until there's a stack overflow error I'm running CF2018 on Windows 10 Pro for development
Comment by David B.
32083 | January 24, 2020 12:13:09 PM GMT