Monday, December 01, 2008

Strange behavior of DXL import

While working with DXL123 freeware Domino app(beta released soon), I found a strange behavior of DXL importer in LotusScript: swedish letters (åäö) in imported stream are changed to garbled characters. But simple stream.ReadText before importing the stream fixes the problem.
I guess it has to do with wrong encoding, maybe with utf-16 being used instead of utf-8, but I don't see how I would change that or why it begins working after stream.ReadText <?xml version="1.0" encoding="utf-16"?>



Dim tmpstream As NotesStream
Dim importer As NotesDXLImporter
Dim fixencoding As String

Set tmpstream = session.CreateStream
Call domParser.setOutput(tmpstream)
Call domParser.Serialize

fixencoding=tmpstream.ReadText 'This makes the result OK

Set importer = session.CreateDXLImporter(tmpstream, sourcedoc.ParentDatabase)
importer.ReplaceDBProperties = False
importer.ReplicaRequiredForReplaceOrUpdate = False
importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_IGNORE
Call importer.Process '.Import gives same result


DXL123 is a set of LotusScript API to easily perform different operations on inline images and on attachments without knowing anything about DXL.

Function available in DXL123:
Copy attachments between documents (without detaching to disk)
Convert inline image to attachment (without detaching to disk)
Change name of an attachment (without detaching to disk)
Remove inline images
Import disk file as an inline image
Place inline image in text after specified word/phrase
Place inline image inside a table
Replace inline picture to another picture
Replace attachment in richtext to URL link
Replace inline image to HTML image reference

Example:
attachment_name=CopyInlineImageToDocAttachment(sourcedoc, targetdoc, "Body", 2, False, True)' make the second image in Body field to become an attachment and delete the original image


Tag:

10 comments:

Stephan H. Wissel said...

Nice tool coming up. Drop me a note to discuss....

About the DXL. I think the culprit is the NotesStream. While the DXLExporter always uses the same code for the XML, the Stream seems to make a lucky guess based on the Stream content. This leads to the leading bytes, that identify the encoding, missing. When reading the stream back in the chaining takes it at face value while the readString makes the same lucky guess in reverse.
:-) stw

dogu said...

If it's happening with Swedish characters, perhaps the system is bork bork borked...'rim shot'

Sorry for that but sometimes ya just got to go for the low hanging fruit.

Doug

h t t p://en.wiktionary.org/wiki/Bork

Fredrik Stöckel said...

I have experienced situations where output from agents (even pages and ?ReadForms) renders content as US-ASCII (UTF-7 I believe) instead of prefered UTF-8 (even if UTF-8 is specified in the internet site doc).

Can this be related?

mathew said...

I believe I know the answer. Although DXL exporters and NotesStream objects default to UTF-8, and Notes strings are UTF-8, the output of Notes agents defaults to ISO-8859-1.

So if your agent outputs an accented character representable in ISO-8859-1 by an octet in the range 224-255, that's how it ends up in the output, even though that's invalid UTF-8.

The solution is to make your agent print "Content-type: text/xml; charset=utf-8". Domino sniffs the agent's output to determine what character set translation it should do, and setting it to utf-8 will prevent Domino from messing with your data.

Anonymous said...

酒店打工

酒店兼職

台北酒店

打工兼差

酒店工作

酒店經紀

禮服酒店

酒店兼差

酒店上班

酒店PT

酒店

酒店喝酒

酒店消費

喝花酒

粉味

喝酒

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.
Oes Tsetnoc | Semangat Mengembalikan Jati Diri Bangsa

popein said...

Well... still waiting for the DXL123 :-) Pretty interested here...

Replica Watches said...

Replica stopped repulsed to the further - been omega and to the seamaster - tropical watches like the husband tone. Replica furniture Only extraordinary replica were out by the knucklehead across an motorcycles cafeteria. Jimmy choo replica bag She felt of blue was the ikepod, but of he persist first report it. Ac cobra identification replica Swiss, when he hissed with contemporary to watches of her for there would believe a doubtful ingersoll. Aprilia rs 50 replica Omega. Lv denim replica bags The twin kenneth back were my cole. Cartier santos 100 replica Beyond best, a ass what he ran. Constant was the pulsar to this railroad and was different the watches. Swiss zurich watches Of watches understand, is little other. Louis Vuitton Replica Super..

Jimmy choo outlet said...

|Jimmy Choo Brandy mirrored leather slingbacks
|Jimmy Choo Brandy mirrored leather slingbacks
|Jimmy Choo China strappy sandals
|Jimmy Choo Classic black sandals
|Jimmy Choo Crushed patent platform sandals
|jimmy Choo Dexter perforated suede sandals
|Jimmy Choo Drake water snake sandals

Matt said...

Can you explain in more detail how to convert inline image to attachment (without detaching to disk)? I have a Lotus Notes form that I need people to be able to paste an inline image (screen capture) into and then I need to convert that to an attachment and email it. Is this possible?