Yuan Yijun (bbbush) wrote,
Yuan Yijun



这两段就是最近一周以来折腾的结果。从网上搜搜看,凡是在 asp+vbscript 里用了 xml 的人都疯了,不管他们抱着多么简单的目的。我也是。

BTW, 还是觉得这些 API 都好烂,不管是微软的 msxml,COM 的 BSTR 编码约定,vbscript
提供的函数,别人设计的国际化参数传递接口,还是自己定义的…… 软件就是一堆堆狗屎 stackup 的结果,一大堆狗屎。

' transformNode() returns BSTR which is always UTF-16. The result may be invalid
' because xslt may specified another encoding (thus header says UTF-16
but content
' is not in result). To use the result, need to use
fso.opentextfile(strPath, ForWriting, True)
' to save to file instead of calling WriteToFile(strPath, resultXml).
' To get correct encoding (specified in xslt), use
transformNodeToObject to avoid
' wrong header, no need to use fso now.
' DO NOT use LoadXmlDOMDoc to load xslDoc, use load() directly because
of the same
' reason: baseOBJ returns BSTR whose header is invalid.
' If transform fails, also check if path is converted to absolute ones.
function TransformXmlDOMDoc(byRef xmlDoc,byRef xslDoc)
    On Error Resume Next
	call InsertG11nParams(xslDoc)
	call SetDefaultDecimalFormat(xslDoc)
	xslDoc.loadXml(xslDoc.xml) ' reload as a workaround to msxml. It is
up to the caller to handle relative path to absolute conversion
	dim result, resultDoc
	set resultDoc = MakeDOM
	result = xmlDoc.transformNodeToObject(xslDoc, resultDoc)
	TransformXmlDOMDoc = "" & resultDoc.xml
	if xslDoc.parseError.errorCode <> 0 then
	    call ReportErrorEx(xslDoc.parseError.errorCode,
xslDoc.parseError.reason, xslDoc.parseError.line & " of file/url " &
	 end If
	if TransformXmlDOMDoc = "" then
	   call ReportError
	end if
end function

' this is essential for us, since now we can use "nothing" as the end
of an array. can only be used in conditional statements.
' if using "var = var" then "resume" is only required(limited) in this function
' if using "var is nothing and not(var is nothing)" then "resume" is
also required in caller if caller is a function. If not in a function,
"resume" is the default action.
' not possible to use "var is var" or "var = "" & var" even with "resume"
function IsString(var)
    On Error Resume Next
    'IsString = var is nothing and not(var is nothing)
    IsString = var = var
end function

问题的关键是我们的代码为了绕开 IE 对 ActiveX 的限制(用户可能在 regedt 中设置各个 ActiveX 的 Compatibility Flag 为禁用),尽量不使用系统的 ActiveX,而是自己写了一个 COM 用来读写文件,而这个 COM 的行为与已有的不一致。我在注释里写不许用 LoadXmlDOMDoc() 或者 WriteToFile(),与设计者的意图背道而驰。可是难道要我去维护那个 COM 吗?(我不知道找谁或者怎么找……群发邮件吧)
Tags: 工作

  • 2020

    Last time I wrote a review was in 2018, about 2017. Or maybe I wrote something elsewhere, maybe on Twitter? It was hard to write something freely…

  • #thotcon badge?

    [root@m4700 ~]# esptool write_flash 0x00000 /home/yuan/tracking/thotcon0x9/tc0x9.bin esptool.py v2.3.1 Connecting.... Detecting chip type...…

  • Portfolio weighted averages

    Last week I got an assignment to make a small Java library for some often used portfolio calculations. A portfolio is a collection of holdings, each…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded