teaman
05/08/2023, 4:42 PMMichael Schmidt
05/08/2023, 4:51 PMAdam Cameron
teaman
05/08/2023, 7:40 PM<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="(path to xml schema)" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="<http://www.w3.org/TR/REC-html40>">
<cols><col min="1" max="1" width="24"/><col min="2" max="2" width="75"/></cols><sheetData>
<cfloop array="#summaryInfo.criteria#" index="curStruct">
<row><c s="2" t="inlineStr"><is><t>#xmlFormat(curStruct.name)#</t></is></c>
<c s="1" t="inlineStr"><is><t>#xmlFormat(replaceNoCase(curStruct.value, "–", "-","ALL"))#</t></is></c></row>
</sheetData></worksheet>
That is not all the content but the salient part that concerns this issue. I also removed <cfoutput> tag wrappers where needed.
The closing tags then follows <cfset fileClose(wsFile)>teaman
05/08/2023, 7:40 PMteaman
05/08/2023, 7:45 PMAdam Cameron
Adam Cameron
Michael Schmidt
05/08/2023, 8:27 PMteaman
05/08/2023, 8:46 PMteaman
05/08/2023, 8:47 PMMichael Schmidt
05/08/2023, 8:48 PM≤
and ≥
teaman
05/08/2023, 8:50 PMAdam Cameron
encodeForXml
. (eg: https://trycf.com/gist/4deafeea80b71b514c632031f6bfc53c/lucee5?theme=monokai)teaman
05/08/2023, 8:56 PMMichael Schmidt
05/08/2023, 8:57 PMteaman
05/08/2023, 9:02 PM<cfscript>
curStruct.value = "≥ 25";
</cfscript>
<cfsavecontent variable="fileContent">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="<http://schemas.openxmlformats.org/spreadsheetml/2006/main>" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="<http://www.w3.org/TR/REC-html40>">
<cols>
<col min="1" max="1" width="24"/>
<col min="2" max="2" width="75"/>
</cols>
<sheetData>
<row>
<c s="2" t="inlineStr"><is><t><cfoutput>#xmlFormat('Surface')#</cfoutput></t></is></c>
<c s="1" t="inlineStr"><is><t><cfoutput>#xmlFormat(replaceNoCase(curStruct.value, "–", "-", "ALL"))#</cfoutput></t></is></c>
</row>
</sheetData>
</worksheet>
</cfsavecontent>
<cfscript>
filePath = getTempDirectory() & "mine.xml";
wsFile = fileOpen(filePath, "write");
fileWrite(wsFile, fileContent);
fileClose(wsFile);
</cfscript>
Adam Cameron
Adam Cameron
teaman
05/08/2023, 9:19 PMAdam Cameron
https://i2.paste.pics/38b4745656c3ece12981b8162ea645ed.png▾
teaman
05/08/2023, 9:22 PMAdam Cameron
<cfprocessingdirective pageencoding="UTF8">
at the top of your file as you have non-ascii stuff in it. I thought CF had fixed this, but I had to do it to even get the char into the XML.
Second... you were making a rod for your own back even involving Excel in the mix here. That code you gave me doesn't even generate the XML properly, so Excel deg ain't gonna be able to fix that.Adam Cameron
wsFile = fileOpen(filePath, "write", "UTF8");
fileWrite(wsFile, trim(fileContent), "UTF8");
teaman
05/08/2023, 9:27 PMAdam Cameron
encodeForXml
non-ascii stuff when building the XML. If I do that, I don't need to tell the file-ops to use UTF-8, as it won't matter.Adam Cameron
Adam Cameron
Adam Cameron
teaman
05/08/2023, 9:28 PMAdam Cameron
teaman
05/08/2023, 9:30 PMteaman
05/08/2023, 9:31 PMteaman
05/08/2023, 9:35 PMAdam Cameron
Adam Cameron
teaman
05/08/2023, 9:40 PMAdam Cameron
teaman
05/08/2023, 9:57 PMAdam Cameron
Adam Cameron
Adam Cameron
teaman
05/08/2023, 10:00 PMAdam Cameron
teaman
05/08/2023, 10:13 PMteaman
05/08/2023, 10:14 PM<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cfscript>
curStruct.value = 'encodeForXml("≥≤") 25';
</cfscript>
<cfsavecontent variable="fileContent">
<worksheet xmlns="<http://schemas.openxmlformats.org/spreadsheetml/2006/main>" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:html="<http://www.w3.org/TR/REC-html40>">
<cols>
<col min="1" max="1" width="24"/>
<col min="2" max="2" width="75"/>
</cols>
<sheetData>
<row>
<c s="2" t="inlineStr"><is><t><cfoutput>#xmlFormat('Surface')#</cfoutput></t></is></c>
<c s="1" t="inlineStr"><is><t><cfoutput>#xmlFormat(replaceNoCase(curStruct.value, "–", "-", "ALL"))#</cfoutput></t></is></c>
</row>
</sheetData>
</worksheet>
</cfsavecontent>
<cfscript>
filePath = getTempDirectory() & "mine.xml";
wsFile = fileOpen(filePath, "write", "UTF-8");
fileWrite(wsFile, fileContent, "UTF-8");
fileClose(wsFile);
</cfscript>
<cfoutput>#filePath#</cfoutput>
Adam Cameron
<cfprocesingdiective>
on it.
You're still using xmlFormat
.
Also you've put the encodeForXml
format into the XML string. It's a CFML function, like I said: use it instead of xmlFormat
.Adam Cameron
teaman
05/08/2023, 11:07 PMteaman
05/08/2023, 11:09 PMAdam Cameron
should be able to automatically detect the char set.I think it only looks so far through the file, but don't quote me on that.
as I add a second cfprocessingdirective tag pair or add pageEncoding attribute on the first cfprocessingDirective tag pairI don't believe this, sorry.
cfprocessingdirective
is a compilation directive & that error you're talking about is a runtime one.
Using suppressWhitespace
is a bit archaic though. Why have you got that? If yer doing something in CFML where the whitespace matters, yer probably not doing it right.
Is this a tactic to get rid of the bad whitespace at the top of your XML that you're creating with <cfsavecontent>
? If so... just... don't put it in there in the first place. And use <cfxml>
not <cfsavecontent>
. That's what it's for.Adam Cameron
teaman
05/09/2023, 12:47 AMAdam Cameron
<cfprocessingdirective>
thing is to clear out yer cfclasses
dir and flush yer component cache in case the change of compilation rules somehow screw around with the compiled classes badly. It is absolutely not a problem to have both, and would not change any logic around how functions are loaded.teaman
05/09/2023, 3:41 PMAdam Cameron