Tim
01/31/2024, 9:24 PMTim
01/31/2024, 9:25 PMdswitzer
01/31/2024, 10:46 PMlenient argument as true it works:
https://trycf.com/gist/14d7da559d718dd04577e456d4901df2/lucee5?theme=monokai
I'm guessing that XmlValidate() is "lenient" by default.
I know the XmlParse() was recently updated to make it "secure" by default now, so this might have been part of the change.rstewart
01/31/2024, 10:50 PMrstewart
01/31/2024, 11:07 PMrstewart
01/31/2024, 11:20 PM<cfscript>
sampleXML = '<?xml version="1.0" encoding="UTF-8"?><x:response xmlns:x="<https://demo.sunapsis.iu.edu/ioffice/xml/schema/sunapsis/datalayer>" xmlns:xsi="<http://www.w3.org/2001/XMLSchema>" xsi:schemaLocation="<https://demo.sunapsis.iu.edu/ioffice/xml/schema/sunapsis/datalayer.xsd>"><header><success>false</success><responseInfo/><id>0</id></header><dataset type="null"/></x:response>';
cfhttp(url = "<https://demo.sunapsis.iu.edu/ioffice/xml/schema/sunapsis/datalayer.xsd>", method = "get", result="schema");
try {
xmlObj = XmlParse(sampleXML, true, schema);
}
catch( any error ) {
WriteDump(error);
xmlObj = XmlParse(sampleXML, true);
validation = XmlValidate(xmlObj, schema);
WriteDump(validation);
}
</cfscript>
... although we use a local XSD and schema in the call in our code points to the file on the local filesystem where the above retrieves the schema and then passes it into the XMLParse() call. There's something weird going on with the XMLParse() function's ability to actually get the schema it needs and having the schema either locally or in a variable passed into that first XMLParse() call avoids that weirdness. This brings back lots of bad memories, BTW.rstewart
01/31/2024, 11:23 PM<cfscript>
sampleXML = '<response><header><success>false</success><responseInfo/><id>0</id></header><dataset type="null"/></response>';
cfhttp(url = "<https://demo.sunapsis.iu.edu/ioffice/xml/schema/sunapsis/datalayer.xsd>", method = "get", result="schema");
try {
xmlObj = XmlParse(sampleXML, true, schema);
}
catch( any error ) {
WriteDump(error);
xmlObj = XmlParse(sampleXML, true);
validation = XmlValidate(xmlObj, schema);
WriteDump(validation);
}
</cfscript>
... and goes back to your original XML, but just pulls the schema into a local variable.Tim
02/01/2024, 3:26 AMTim
02/01/2024, 3:22 PMXmlParse(sampleXML, true, schema.fileContent) so i actually have the schema string instead of a cfhttp struct then it starts failing again with the same message as passing a URL or a path.
If I add in the prolog and the namespace/schema declarations then it does work. So I think the lenient idea is correct. But it looks like that param is Lucee only.rstewart
02/01/2024, 5:48 PM