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:

9 comments:

Anonymous 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

Anonymous 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.

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..

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?

Ded said...

Have you ever finished the DXL Library? If not, could you make it available so others could continue the work?

Digital Marketing Company in Delhi said...

We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work.