IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

There's a function in the menu of Domino Designer to export selected design elements into a DXL file (Tools / DXL Utilities / Exporter). However, there's no corresponding function to import design elements from a DXL file into the current database. Since I needed to do that today, I thought I would share the code in case it's of any use the the folks out there in Dominoland.

This script is set to import only design elements, to not require that they came from the same database, and to replace existing design elements with the same name. If that's not what you want, you could of course go in and change those lines. You would use it in an agent set to run on no documents.

Once the import is done, the script also signs the new design elements. This isn't needed for every type of design element, but it is for most and it doesn't harm the others.

Here's the code: dxlimport.lss

Andre Guirard | 20 March 2007 09:52:24 AM ET | Man-Cave, Plymouth, MN, USA | Comments (21)


 Comments

1) The Missing DXL Import Menu Option
Tim Tripcony | 3/20/2007 11:58:11 AM

Andre, is there an option available for replacing an existing element based on UNID instead of name?

2) re: The Missing DXL Import Menu Option
Andre Guirard | 3/20/2007 2:42:00 PM

Offhand, I don't know how to do that. Of course, if the aliases match, the replace will happen, so that lets you change the "user facing" title while still having a matching identifier. What's your application?

Is it really important that the UNIDs remain the same, or did you just want to replace the right design elements? Because you could parse the DXL input yourself prior to importing, read off the UNIDs, and store them (in a List datatype, probably best). Then import, and loop thru the list of imported elements (just as my example code does). As you do that, delete the UNID of every imported document from the list. The remaining list entries represent design notes that were not replaced during the import, presumably because the names didn't match. Use the UNIDs to find those notes and delete them.

3) Replace by UNID
Tim Tripcony | 3/20/2007 8:47:42 PM

Thanks, Andre. The scenario I have in mind is one in which design information is being exported to DXL, modified externally or programmatically, then reimported. If the element is renamed in the process, it creates a duplicate instead of updating the existing element. My current approach is to detect name changes prior to the import, then get a handle on the design element via its UNID, overwrite the $TITLE field with the new name, then perform the import. It works, but I was hoping there was a simpler way.

4) Is not a form - export
Patrick Kwinten | 3/21/2007 4:43:36 AM

Hi,

I have a problem with a form that is corrupt after Notes crashed. If I tried to open the form I get the message 'Is not a form'.

I first did an DXL export which resulted in a fine DXL file with all the info.

When I then do an import via the code you provide I only get an empty form in return.

:-?

5) The Missing DXL Import Menu Option
Kevin Pettitt | 3/21/2007 9:22:05 AM

Great timing Andre, I just yesterday looked at that menu and had to mutter a few choice words when the import option was missing. I also happen to have been looking closely at DXL lately in the context of developing various approaches to "skinning" a Notes client app. I've got a pretty slick working model for applying Action bar attributes to select design elements, using an embedded view to preview the actionbar style before applying to selected elements. It's based on the "ActionBar" OpenNTF project.

I'm hopeful that I'll be able to do something similar with frameset borders and embedded outline backgrounds to apply a new color scheme in one shot. However, even if I don't use DXL to modify those elements in place, I could pretty easily use your code to pull in variations of those elements from a separate "skin" database.

6) re: Is not a form - export
Andre Guirard | 3/21/2007 12:06:45 PM

I don't know... it sounds like maybe there was a problem with the form before you exported it. When you look at the DXL, do you see the stuff that's supposed to be in your form? The fields and so on?

7) Is not a form
John Robayo | 4/7/2007 10:54:32 AM

I have the same problem and not in one opportunity... I had this problem many times.... and I never could recover the form.... always needed to start again.

What can i do? or How can i prevent this problem, cos I lost many develops......

8) The Missing DXL Import Menu Option
Wayne Sobers | 4/10/2007 3:52:56 PM

Is this for a particular version of Notes?

I'm using this code to import your "re-ordering items" form and I'm getting an error during the actual processing.

I'm on Notes 6.5.5 so I'm wondering if the issue is the version difference.

Just get the message "DXL importer failed".

Wayne

9) re: The Missing DXL Import Menu Option
Andre Guirard | 4/10/2007 4:25:12 PM

> Is this for a particular version of Notes?

> I'm using this code to import your "re-ordering items" form and I'm getting an error during the actual processing.

> I'm on Notes 6.5.5 so I'm wondering if the issue is the version difference.

> Just get the message "DXL importer failed".

Oh. The form was designed and exported with version 8.0 beta. I guess the DXL has some new stuff in it that Notes 6.5.5 doesn't recognize, even though there's no reason the form itself shouldn't work. I'll package it up as an NSF and update the blog entry in a bit.

10) Note item not found problem
Thomas Adrian | 4/27/2007 12:39:29 AM

Hello Andre

I have first created one scheduled agent called "Test" and now I want to change the scheduled time frame using a modified version of your script.

The error I get is note item not found, I have tried using different designimportoptions, tried setting the unid and noteid but that does not help.

However if I export the whole agent DXL code , change it, and then import the whole agent DXL code again using your importcode, it works ?

Any ideas what my code is missing in order to change the agent schedule ?

Thanks

Thomas Adrian

{ Link }

On Error Goto oops ' standard error trapping

Dim session As New NotesSession

Dim dxli As NotesDXLImporter

Dim db As NotesDatabase

Dim stream As NotesStream

Dim inputfile

Dim wksp As New NotesUIWorkspace

Set stream = session.CreateStream

stream.WriteText(|<?xml version='1.0' encoding='utf-8'?><agent name="Test">|)

stream.WriteText(|<trigger type="scheduled"><schedule type="byminutes" hours="12" minutes="2" runlocation="local" /></trigger></agent>|)

Set db = session.CurrentDatabase

Set dxli = session.CreateDXLImporter(stream, db)

dxli.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE

dxli.ACLImportOption = DXLIMPORTOPTION_IGNORE

dxli.DocumentImportOption = DXLIMPORTOPTION_IGNORE

dxli.ReplicaRequiredForReplaceOrUpdate = False

dxli.ReplaceDBProperties = False

dxli.Process

' if the import succeeded, sign the new design notes.

If dxli.ImportedNoteCount Then

Dim strID$

strID = dxli.GetFirstImportedNoteId()

Do Until strID = ""

Dim docDesign As NotesDocument

Set docDesign = db.GetDocumentByID(strID)

Call docDesign.Sign()

Call docDesign.Save(True, False, True)

strID = dxli.GetNextImportedNoteId(strID)

Loop

End If

Exit Sub

oops:

Msgbox "Error " & Err & " line " & Erl & ": " & Error

Exit Sub

11) Note item again...
Thomas Adrian | 4/27/2007 12:42:26 AM

Missed to tell you one thing, The script I did above runs without problem, no errors what so ever, but when I try to access the agent "Test" I get Note item not found.

Thomas

www.notessidan.se

12) Well, found the cause but not the solution
Thomas Adrian | 4/27/2007 2:16:10 AM

Well, I did some more tests.

It seems as I get the "note info not found" if the xml code sent to the importer does not contain any code.

i.e if I add the following xml to the script above it works fine, the problem is that I do not want to modify the code ?

Is this a bug ?

<code event='initialize'><lotusscript>Sub Initialize

Print ""

End Sub</lotusscript></code>

Thomas Adrian { Link }

13) re: Well, found the cause but not the solution
Andre Guirard | 4/27/2007 8:34:29 AM

Thomas,

It seems you're expecting that only the parts of the agent DXL that you include tags for will be replaced. In fact, every item is removed from the design note and replaced with data from the DXL. So you need to fully specify the agent in your DXL, including all the source code. To make one little change in an existing agent, start by exporting the agent to a parser -- the DOM parser is good for this -- to find the tag whose attributes you need to modify and replace the relevant values, then import the resulting XML.

14) Ofcourse
Thomas Adrian | 4/27/2007 12:26:03 PM

Thank you, I did not think of that. the designimport options does not support update , only documentimportoptions do.

/Thomas

15) Not a form
vinay | 10/24/2007 7:15:57 AM

I m not able to access my form in designer . Pops up "Not form"

can u help me ?

16) vinay
jitesh | 12/27/2007 12:25:55 AM

Dear vinay,

i m facing the same problem in one fo my forms. I hope u have kept a back-up. It seems to be that some access formula seems to be causing the problem.

Will tell u if i find out.

17) The Missing DXL Import Menu Option
Kevin Pettitt | 2/25/2008 11:36:44 AM

Andre, I tried to use this import agent to pull in the defaultform dxl you posted here: { Link } but it failed. Using 8.0.1. You mentioned updating this entry with an nsf, and I was thinking maybe you could put the defaultform in there as well.

Thanks.

18) It seems that Export and Import has to be done with exact same version ?
Knud Erik Hojslet | 12/10/2008 5:40:46 AM

I have added your import-agent to my apps, which are used by hundreds of companies. Now I have a minor error in an agent, that I was hoping to be able to fix by sending them a DXL-file with the new code. But unfortunately, it seems that they can only import in their client, if the export was done with exact the same version of Notes.

Any suggestions to make it backwards compatible mostly welcome (mail: keh@hojslet.dk)

19) I get an error while Importing DXL file that," DXL file cannot be imported "
Kesavan | 12/24/2008 6:47:52 AM

I have imported DXL file it gives Lotus notes error notification while I run an exe..

20) Just edit the DXL-file to reflect the notes-version of the client importing the DXL
Knud Erik Hojslet | 2/19/2009 1:29:13 PM

Question: Can I modify the DXL so that any 6.5+ client will be able to import it ?

Sure you can. Within the DXL file there will be a reference to domino_8_0_2.dtd or domino_8_0_2.xsd. Change that to domino_6_5.dtd or domino_6_5.xsd and the import should work. Currently the import is failing for your customer is because the importer is looking for domino_8_0_2.dtd/xsd with the xmlschemas directory with the data directory on your customers machine.

Regards

- Sumeet

_____________________________

Sumeet Toprani, Project Manager

Lotus Software, IBM Software Group

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact