Google Box
 News
  Tips Home :

How to extract Lotus Notes design elements from a dxl export a basic tutorial and demonstration.

Doc TypeTips & Tricks
Email SettingMake Public
Email Addresssteve dot robinson at notes411 dot com
Keep informed?Yes
AuthorS C Robinson
Company NameNotes411
CategoryDXL, LotusScript, XML, XSL
Modified 21/08/2006 17:05:00
Subject How to extract Lotus Notes design elements from a dxl export a basic tutorial and demonstration.


Part 1.


This tutorial covers how to create a simple agent that will extract an action bar design element from a notes form.


Our sample database only has one form and in this form we have one action button. What we want to do is generate the DXL for this action button so we can change some properties of the action buttons then re-import the DXL.

I have attached the sample database a the end of this article. It is called snapper.nsf. The database contains a form called 'test' and it contains an action button.


Below are the steps to play with the sampe code.


Step 1.


Create an Agent called 'GetActionButton'




Make sure the agent's 'Target' is set to 'None' this will allow the agent to be run from the actions menu.


Step 2
. Copy in the following code, which will do the transformation. You will have to ensure you add a %include statement in the declarations section of the agent to allow the use of the error constants.
Sub Initialize
   Dim session As New NotesSession

   Dim db As NotesDatabase

   Set db = session.CurrentDatabase

   
REM Open xml file named after current database

   Dim stream As NotesStream

   Set stream = session.CreateStream

   filename$ = "c:\temp\" & Left(db.FileName, Len(db.FileName) - 3) & "xml"

   If Not stream.Open(filename$) Then

           Messagebox "Cannot open " & filename$,, "Error"

           Exit Sub

   End If

   Call stream.Truncate

   
REM Export current database as DXL

   Dim exporter As NotesDXLExporter

   Set exporter = session.CreateDXLExporter

   
   REM Create note collection of actions

   Dim nc As NotesNoteCollection

   Set nc = db.CreateNoteCollection(False)

   Call nc.SelectAllFormatElements(True)

   nc.SelectActions = False

   Call nc.BuildCollection

   
REM Set up importer to receive DXL piped from exporter

REM and to re-import the documents back into the
REM current database as copies.

   Set exporter = session.CreateDXLExporter(nc)

   
   Call exporter.SetInput(nc)

   Call exporter.SetOutput(stream)

   'There are two kinds of XML-valid and well-formed.
'Valid XML has a DTD.
'Well-formed XML has no DTD, but is properly constructed-all entities are declared, properly closed, and correctly nested.
'The XML specification makes a DTD optional.
'Well-formed XML is self-documenting and can be processed without a DTD.
'Valid XML cannot.

   exporter.OutputDOCTYPE = False ' Stops the <!DOCTYPE database SYSTEM 'xmlschemas/domino_7_0.dtd'> from being added to output.

   Call exporter.Process

End Sub





At the bottom of this article I have attatched an XML file which contains an export of the database design as DXL.


I have also attached an XSLT file which contains the XPATH expression to filter out only the nodes defined for the actionbar, which contains the actions properties.


The snapper.xsl file contains the XSLT information as shown below.
<?xml version="1.0" encoding="UTF-8" ?>
<
xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:dxl='http://www.lotus.com/dxl'>

<
xsl:template match='/'>
<
xsl:copy-of select="//dxl:actionbar"/>
</
xsl:template>  
</
xsl:stylesheet>





The snapper.xml file will contain the exported design action elements as shown below.
<?xml version='1.0' encoding='utf-8'?>
<
database xmlns='http://www.lotus.com/dxl' version='7.0' replicaid='802571420024C3CB'
path
='stever\snapper.nsf' title='snapper'>
<
databaseinfo dbid='802571420024C3CB' odsversion='43' diskspace='663552' percentused='71.9521604938272'
numberofdocuments
='0'><datamodified><datetime dst='true'>20060823T152627,95+01</datetime></datamodified><designmodified
><
datetime dst='true'>20060823T164349,74+01</datetime></designmodified></databaseinfo>
<
form name='Test' publicaccess='false' designerversion='7' renderpassthrough='true'>
<
noteinfo noteid='16a' unid='7DDE82A2BDDE3546802571D1003611CC' sequence='13'>
<
created><datetime dst='true'>20060821T105035,00+01</datetime></created>
<
modified><datetime dst='true'>20060823T162037,47+01</datetime></modified>
<
revised><datetime dst='true'>20060823T162037,46+01</datetime></revised>
<
lastaccessed><datetime dst='true'>20060823T162037,46+01</datetime></lastaccessed>
<
addedtofile><datetime dst='true'>20060821T105127,19+01</datetime></addedtofile></noteinfo>
<
updatedby><name>CN=Steve Robinson/O=DominoSource</name></updatedby>
<
wassignedby><name>CN=Steve Robinson/O=DominoSource</name></wassignedby>
<
actionbar bgcolor='#d4d0c8' bordercolor='black'>
<
actionbuttonstyle bgcolor='#d4d0c8'/><font size='15pt' color='system'/><border
style
='solid' width='0px 0px 1px'/>
<
action title='Save'><code event='click'><formula>@Command([FileSave])</formula></code><code
event
='label'><formula>Close</formula></code></action></actionbar>
<
body><richtext>
<
pardef id='1'/>
<
par def='1'/></richtext></body>
<
item name='OriginalModTime'><datetime dst='true'>20060823T162037,45+01</datetime></item>
<
item name='$$ScriptName' summary='false' sign='true'><text>Test</text></item></form></database>






Step 3.


Run the 'Export' agent and it export the DXL we need


Step 4.


Detach the snapper.xsl file from this article and place it in the c:\temp\ folder.


Step 5.


Run the Agent 'GetActionBar' the resulting snapper_out.xml file will contain a subset of the dxl i.e the actionbar data only.
<?xml version="1.0" encoding="UTF-8"?>
<
actionbar bgcolor="#d4d0c8" bordercolor="black" xmlns="http://www.lotus.com/dxl">
   
<actionbuttonstyle bgcolor="#d4d0c8"/>
   
<font size="12pt" color="system"/>
   
<border style="solid" width="0px 0px 1px"/>
   
<action title="Save">
           
<code event="click">
                   
<formula>@Command([FileSave])</formula>
           
</code>
           
<code event="label">
                   
<formula>Close</formula>
           
</code>
   
</action>
</
actionbar>





We really need to do more work on this sample to show how to use this technique to filter out un-wanted design elements from exported DXL then import the design back in to the database, thus giving us the ability to add & remove design elements. We could also use this technique to update/change design elements.
Part 2 of this  DXL tutorial will explain how to do this.

Tutorial files:

snapper.xsl

snapper.xml

snapper.nsf (Lotus Notes 7.0)



Document Iconsnapper.xslType: application/octet-stream
Name: snapper.xsl

Document Iconsnapper.xmlType: application/octet-stream
Name: snapper.xml

Document Iconsnapper.nsfType: application/vnd.lotus-notes
Name: snapper.nsf


Add Response   ||  Add a Document



Responses to "How to extract Lotus Notes design elements from a dxl export a basic tutorial and demonstration.":

© 2003 notes411.com. All rights reserved. Disclaimer. site designed & developed by appsworks.com
Lotus Notes is a registered trademark of IBM. This site is not affiliated with IBM or Lotus.