I think you could simplify your first approach a little by reverting to calling OpenStream on your reader object rather than using OpenFile:
// 1st approach - it succeeds, so the file errorOpenFile.xml is NOT generated
//
d msg.Value.Rewind()
set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="D:\DATABASES\OVPATH\temp\test.xml"
set fs.TranslateTable = "UTF8"
set tSC=fs.CopyFrom(msg.Value)
set tSC=fs.%Save()
s reader=##class(%XML.Reader).%New()
d fs.Rewind() // might not be necessary, but won't hurt
Set sc = reader.OpenStream(fs)
Anyhow, the fact that you don't get an error confirms my hypothesis that the original stream (msg.Value) contains Unicode data but the reader treats it as though it is UTF8-encoded.
In your code above I think you can also omit the line where you set fs.Filename and instead allow the stream to generate its own temporary file. Explicitly naming the file may be handy when debugging, but it will cause problems if more than one process runs this code concurrently.
- Log in to post comments




