Lotuser advanced series -- dxl's Domino design through program modification

Source: Internet
Author: User
Original Author: I worship snow waves Fox
In Domino R6, you can export design elements and generate a dxl (Domino XML) document. After export, we can use Program Code Modify the dxl document and then import the modified Code to the domino database. In this way, you can modify any code in the design element (for example, add or delete the child form inserted in the form, modify the code in the proxy, and add or delete columns in the view ).

Note the following points::
1. After proxy re-import
A) when the design is enabled, the system will prompt that the proxy is not signed and cannot be opened. When the proxy is running on the Web, the server will be down immediately. Solution: Open the design element document with a program and sign it.
B) if the original proxy has two names (for example, "Save proxy | ag_savedoc"), the name of the imported proxy will be changed to "save proxy | ag_savedoc". On the design page, A space is automatically added before the English name of the proxy, but this does not affect the proxy call, but the design cannot be obtained normally in the Koa interface. Solution: Open the design element document with a program and modify the $ title domain.

2. After the view is re-imported, if the view name (note, not alias) conflicts, the imported view is automatically renamed to "original view name" + "/" + "Current User Account" (for example: "By Department" will be changed to "by department/CN = Xue Lang Hu/o = Dev"). If the renamed name still conflicts, the dxl import failure error is reported in the imported program. Solution: Open the design element document with a program and modify the $ title domain.

3. When there are a lot of exported design code, the export code to the memory will be somewhat delayed. If the subsequent Code directly accesses the variables in the memory, errors often occur. Solution: first put the exported code in a temporary file, and then read the content from the file to the memory.

Sample Code:

Import code programs

Dim exporter as notesdxlexporter
Dim stream as notesstream

Set view = dB. getview ("sys_vh_designbyname ")
Set Doc = view. getdocumentbykey (elemname, true)
If not Doc is nothing then
Set stream = ss. createstream
Call stream. Open ("C: \ $ lksdesigninfo. dxl", "UTF-8") 'export files to address the buffer issues mentioned earlier
Stream. truncate 'clear the original content of the file
Set exporter = ss. createdxlexporter (Doc, Stream)
Call exporter. Process' to export code to a file
Stream. Close
Set stream = ss. createstream
Call stream. Open ("C: \ $ lksdesigninfo. dxl", "UTF-8 ")
Elementcode = stream. readtext 'reads the File Content
'The following code gets the XML snippet of the design element
Elemtype = strrightback (rtnval, "</")
Elemtype = strleft (elemtype, "> ")
Elementcode = "<" & elemtype & "" & strright (elementcode, "<" & elemtype &"")
Elementcode = strleftback (elementcode, "> ")
If elementcode <> "" then
Elementcode = elementcode & ">"
End if
Call stream. Close
Kill "C :\$ lksdesigninfo. dxl"
End if

Import code programs

Dim stream as notesstream
Dim importer as notesdxlimporter

Codetxt = {<? XML version = '1. 0' encoding = 'utf-8'?>} & CHR (10)
Codetxt = codetxt & {<! Doctype Database System 'xmlschemas/domino_6_5_3.dtd '>}& CHR (10)
Codetxt = codetxt & {<database xmlns = 'HTTP: // www.lotus.com/dxl' version = '6. 5' maintenanceversion = '3. 0' >}& CHR (10)
Codetxt = codetxt & elementcode Add the XML snippet of the obtained element code
Codetxt = codetxt & "</database>" & CHR (10)
Set view = dB. getview ("sys_vh_designbyname ")
Set stream = ss. createstream
Call stream. writetext (codetxt) 'writes code information to the stream
Set importer = ss. createdxlimporter (stream, objdb)
Importer. designimportoption = dxlimportoption_create
Call importer. process' Import
Call stream. Close
If isarray (newlist) then 'newlist stores the names of all the design elements you just imported.
Newlist = com_uniquetrim (newlist)
Forall o in newlist
Set Doc = view. getdocumentbykey (O, true)
If Doc is nothing then
Set Doc = view. getdocumentbykey ("" & O, true) 'the element name in the proxy may be added with spaces
End if
If not Doc is nothing then
If Doc. hasitem ("$ title") then' modify the $ title field in the design element
Title = Doc. getitemvalue ("$ title ")
Haschg = false
If instr (title (0), "|")> 0 then
Title (0) = com_replacesubstring (title (0), "|", "| ")
Haschg = true
End if
If instr (title (0), "/CN =")> 0 then
Tmpstr = strright (title (0), "/CN = ")
If instr (tmpstr, "|") then
Title (0) = strleft (title (0), "/CN =") & "|" & strright (tmpstr, "| ")
Else
Title (0) = strleft (title (0), "/CN = ")
End if
Haschg = true
End if
If haschg then
Call Doc. replaceitemvalue ("$ title", title)
End if
End if
Call Doc. sign' sign the design
Call Doc. Save (True, true)
End if
End forall
End if

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.