Your SlideShare is downloading. ×
0
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Dxl As A Lotus Domino Integration Tool
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Dxl As A Lotus Domino Integration Tool

4,728

Published on

Dxl As A Lotus Domino Integration Tool

Dxl As A Lotus Domino Integration Tool

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
4,728
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Transcript

    • 1. DXL as a Lotus Domino Integration Tool Dick Annicchiarico IBM
    • 2.  
    • 3. Agenda <ul><li>Quick review of XML, DXL, and XSLT </li></ul><ul><li>Overview of the Domino application used in the demos – Customer Orders </li></ul><ul><li>Demos and source code overview of using DXL </li></ul><ul><ul><li>as input or output from Web service APIs (USPS and Amazon) </li></ul></ul><ul><ul><li>to create a PDF (Portable Document Format) report document </li></ul></ul><ul><ul><li>to export data to or import data from an OpenOffice spreadsheet </li></ul></ul><ul><li>Q & A </li></ul>
    • 4. XML <ul><li>eXtensible Markup Language </li></ul><ul><li>By itself, just a set of rules for properly formed elements, content, attributes, and attribute values </li></ul><ul><li>There are many, many XML vocabularies, e.g. DXL, XSL, Web service APIs, OpenOffice, etc. </li></ul><ul><li>XML vocabularies are specified via a DTD or schema </li></ul>
    • 5. DXL – Domino XML Language <ul><li>DXL is XML </li></ul><ul><li>DXL defines XML elements for most Domino constructs, e.g. database, acl, document, form, view, agent, etc. </li></ul><ul><li><document>s are very general; mainly a collection of <item>s </li></ul><ul><li>Other elements are much more abstract; not just a collection of <item>s </li></ul><ul><li>Lowest form of any note is the <note> element </li></ul><ul><ul><li>slightly more general than <document> </li></ul></ul><ul><li>This presentation focuses on <document>s </li></ul>
    • 6. Example DXL Document <ul><li><?xml version='1.0' encoding='utf-8'?> </li></ul><ul><li><!DOCTYPE document SYSTEM 'xmlschemas/domino_6_5.dtd'> </li></ul><ul><li>< document xmlns='http://www.lotus.com/dxl' version='7.0' replicaid='85256DF8005772E9' form=' Customer '> </li></ul><ul><li>< item name='customerid'><text> 00925264444 </text></item> </li></ul><ul><li>< item name='name'><text> Robert Harold </text></item> </li></ul><ul><li>< item name='address'><text> 34 Grand Blvd </text></item> </li></ul><ul><li>< item name='city'><text> Oklahoma City </text></item> </li></ul><ul><li>< item name='state'><text> OK </text></item> </li></ul><ul><li>< item name='zip'><text> 73116 </text></item> </li></ul><ul><li></document> </li></ul>
    • 7. Example DXL Form <ul><li><?xml version='1.0' encoding='utf-8'?> </li></ul><ul><li><!DOCTYPE form SYSTEM 'xmlschemas/domino_6_5.dtd'> </li></ul><ul><li>< form name='Simple' xmlns='http://www.lotus.com/dxl' version='7.0' replicaid='85256DF8005772E9‘ publicaccess='false' designerversion='6.5'> </li></ul><ul><li>< actionbar bgcolor='#ece9d8' bordercolor='black'> </li></ul><ul><li>< action title='Hello'>< code event='click' >< formula >@Prompt([Ok]; &quot;Sample Action&quot;; &quot;Hello, World&quot;)</formula></code></action> </li></ul><ul><li></actionbar> </li></ul><ul><li>< body > </li></ul><ul><li>< richtext > </li></ul><ul><li><pardef id='1'/> </li></ul><ul><li><par def='1'>Text field: </li></ul><ul><li>< field type='text' kind='editable' name='fieldText'/> </li></ul><ul><li></par> </li></ul><ul><li></richtext> </li></ul><ul><li></body> </li></ul><ul><li></form> </li></ul>
    • 8. Example DXL Form as a Note <ul><li><?xml version='1.0' encoding='utf-8'?> </li></ul><ul><li><!DOCTYPE note SYSTEM 'xmlschemas/domino_6_5.dtd'> </li></ul><ul><li>< note class='form' xmlns='http://www.lotus.com/dxl' version='7.0' replicaid='85256DF8005772E9'> </li></ul><ul><li>< item name='$HTMLCode' sign='true'> </li></ul><ul><li><itemdata type='1'>X/8QAAIADwAHAAAAAAAAAA==</itemdata></item> </li></ul><ul><li>< item name='$TITLE'><text>Simple</text></item> </li></ul><ul><li>< item name='$Info' sign='true'><itemdata type='1'> </li></ul><ul><li>hhgBAIAAAAAAgAAAAQABAP///wAQAAAA</itemdata></item> </li></ul><ul><li>< item name='$Flags'><text/></item> </li></ul><ul><li>< item name='$DesignerVersion'><text>6.5</text></item> </li></ul><ul><li>< item name='$Fields'><text>fieldText</text></item> </li></ul><ul><li>< item name='$Body' sign='true'><richtext> ... </richtext></item> </li></ul><ul><li>< item name='$V5ACTIONS' sign='true'> </li></ul><ul><li><itemdata type='1'> ... </itemdata></item> </li></ul><ul><li></note> </li></ul>
    • 9. XSLT – eXtensible Stylesheet Language Transformations <ul><li>A language and tool for transforming XML into different XML data or other formats (HTML, CSV, etc.) </li></ul><ul><li>Uses XPath (XML Path Language) to access parts of an XML document (e.g. a specific attribute value) </li></ul>XSLT Processor XML document XSLT stylesheet Output document
    • 10. Overview of the Application - Customer Orders <ul><li>Customer and order information in a Domino database </li></ul><ul><li>Interacts with a USPS (United States Postal Service) server to get shipping rates </li></ul><ul><li>Generates a report of selected orders in PDF format </li></ul><ul><li>Exports data to and imports data from an OpenOffice spreadsheet </li></ul><ul><li>Browses products on amazon.com and generates summary documents </li></ul>
    • 11. Overview of the Database – orders.nsf <ul><li>Customers and Orders views contain the customer data </li></ul><ul><li>Search Results view contains results of browsing for products </li></ul><ul><li>Stylesheets view contains XSL stylesheets for the various data transformations in the demos </li></ul><ul><li>Agents and script libraries contain the code (Java and LotusScript) to export, import, transform to/from DXL </li></ul><ul><li>Programs view contains configuration information </li></ul><ul><ul><li>Used by agent and script library code to interface with other software products used in the demos </li></ul></ul>
    • 12. Setup Steps Before Using orders.nsf (1) <ul><li>Download and install prerequisite software </li></ul><ul><ul><li>PDF Composer – demo uses FOP, Formatting Objects Processor, http://xml.apache.org/fop </li></ul></ul><ul><ul><li>PDF Viewer – demo uses Adobe Reader, http://www.abobe.com/products/acrobat/readermain.html </li></ul></ul><ul><ul><li>OpenOffice – http://www.openoffice.org </li></ul></ul><ul><ul><li>Zip and Unzip utilities </li></ul></ul><ul><li>Create/edit documents in Programs view that specify location of and how to invoke the above programs </li></ul>
    • 13. Setup Steps Before Using orders.nsf (2) <ul><li>Obtain a USPS UserId and Password for making Web service rate requests </li></ul><ul><ul><li>http://www.uspswebtools.com/registration </li></ul></ul><ul><ul><li>Demo code obtains this data from plain text files C:demoUspsUserId.txt and C:demoUspsPassword.txt </li></ul></ul><ul><li>Obtain an Amazon Developer Token for making Web service product searches </li></ul><ul><ul><li>http://www.amazon.com – click on Web Services link </li></ul></ul><ul><ul><li>Demo code obtains this data from plain text file C:demoAmazonDeveloperToken.txt </li></ul></ul>
    • 14. Summary of Demos <ul><li>Use a USPS Web service API to obtain postage amounts for packages, and update the Domino order documents </li></ul><ul><li>Format order information into XSL:FO (Formatting Objects) and use a third party tool to translate into a PDF document </li></ul><ul><li>Export order information to an OpenOffice spreadsheet; Modify orders and import changes back into Domino </li></ul><ul><li>Use an Amazon Web service to browse for products and summarize results in a tabular format in a Domino document </li></ul>
    • 15. Demo 1: USPS Web Service <ul><li>USPS provides a Web service for calculating shipping costs based on size and weight of package, source and destination shipping locations, and other parameters </li></ul><ul><ul><li>Request is made via a standard URL that contains a <RateRequest> in XML format </li></ul></ul><ul><ul><li>USPS Web server answers back with a <RateResponse> in XML format </li></ul></ul><ul><li>Domino XSLT and DXL support is used to update order documents with shipping cost </li></ul>
    • 16. Demo 1: USPS Web Service DXL Importer RateRequest URL Domino Order documents USPS Web Service Rate Response XML RateResponse 2Document XSL DXL documents (updates) XSLT Processor
    • 17. Demo 1: Code Summary <ul><li>Calculate Shipping agent (Java) </li></ul><ul><li>See Java Debug Console for URL built by the code from data in Domino documents </li></ul><ul><li>URLLoader class from JavaUtilClasses script library loads the URL – response captured in C: mpRateResponse.xml </li></ul><ul><li>XSLTTransformer class from JavaUtilClasses script library transforms the response into DXL – see C: mpUpdates.dxl </li></ul><ul><ul><li>Uses transformXML method of Item class to do transform </li></ul></ul><ul><li>Transform used is RateResponse2Document.xsl in Stylesheets view </li></ul><ul><li>DxlImporter updates documents with shipping data </li></ul>
    • 18. Demo 1: Calculate Shipping agent (Java) <ul><li>// Build the request URL. </li></ul><ul><li>... </li></ul><ul><li>// Load rate request URL and capture the response to a file. </li></ul><ul><li>URLLoader urlLoader = new URLLoader(); </li></ul><ul><li>urlLoader.load(url, rateResponseXmlFile); </li></ul><ul><li>... </li></ul><ul><li>// Transform the response into DXL to update order documents. </li></ul><ul><li>XSLTTransformer transformer = new XSLTTransformer(session); </li></ul><ul><li>transformer.transform(rateResponseXmlFile, db, response2DocumentXsl, updatesDxlFile); </li></ul><ul><li>... </li></ul><ul><li>// Import the DXL file in UPDATE_ELSE_IGNORE mode. </li></ul><ul><li>DxlImporter importer = session.createDxlImporter(); </li></ul><ul><li>importer.importDxl(dxlStream, db); </li></ul>
    • 19. Demo 1: Sample Request URL <ul><li>http://production.shippingapis.com/ShippingAPI.dll?API=Rate&XML=< RateRequest %20USERID=‘XXXXXXXXXXXX'%20PASSWORD=‘XXXXXXXXXXXX'>< Package %20ID=' 31D95736B4AC17F985256E000055258D '><Service> Priority </Service><ZipOrigination> 01886 </ZipOrigination><ZipDestination> 53204 </ZipDestination><Pounds> 3 </Pounds><Ounces> 0 </Ounces><Container> None </Container><Size> Regular </Size><Machinable> True </Machinable>< /Package > </RateRequest > </li></ul>
    • 20. Demo 1: URLLoader class <ul><li>public class URLLoader </li></ul><ul><li>{ </li></ul><ul><li>public void load(String urlString, String filename) throws java.net.MalformedURLException, java.io.IOException </li></ul><ul><li>{ </li></ul><ul><li>InputStream in = null; </li></ul><ul><li>OutputStream out = null; </li></ul><ul><li>// A nice Java class makes this easy to do. </li></ul><ul><li>URL url = new URL(urlString); </li></ul><ul><li>in = url.openStream(); </li></ul><ul><li>out = new FileOutputStream(filename); </li></ul><ul><li>// Read up the response and write it to the specified file. </li></ul><ul><li>... </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
    • 21. Demo 1: Sample RateResponse.xml <ul><li><?xml version=&quot;1.0&quot; ?> </li></ul><ul><li><RateResponse> </li></ul><ul><li>< Package ID=&quot; 31D95736B4AC17F985256E000055258D &quot;> </li></ul><ul><li><Service> Priority </Service> </li></ul><ul><li><ZipOrigination> 01886 </ZipOrigination> </li></ul><ul><li><ZipDestination> 53204 </ZipDestination> </li></ul><ul><li><Pounds> 3 </Pounds> </li></ul><ul><li><Ounces> 0 </Ounces> </li></ul><ul><li>  <Container> NONE </Container> </li></ul><ul><li><Size> REGULAR </Size> </li></ul><ul><li><Machinable> TRUE </Machinable> </li></ul><ul><li><Zone> 5 </Zone> </li></ul><ul><li>< Postage > 6.85 </Postage> </li></ul><ul><li></Package> </li></ul><ul><li></RateResponse> </li></ul>
    • 22. Demo 1: XSLTTransformer class <ul><li>public void transform(String xmlFilename, Database xsltDb, String xsltDocumentName, String outFilename) </li></ul><ul><li>throws NotesException, FileNotFoundException, IOException </li></ul><ul><li>{ </li></ul><ul><li>Database db = mSession.getDatabase(null, scratchDbName, true); </li></ul><ul><li>Document doc = db.createDocument(); </li></ul><ul><li>// Copy the input file to a text item. </li></ul><ul><li>... </li></ul><ul><li>Item xmlItem = doc.replaceItemValue(&quot;XMLSource&quot;, sb.toString()); </li></ul><ul><li>// Create an InputSource from the String containing the XSLT. </li></ul><ul><li>String xsltStr = Util.getStylesheet(xsltDb, xsltDocumentName); </li></ul><ul><li>StringReader xsltRdr = new StringReader(xsltStr); </li></ul><ul><li>InputSource xslt = new InputSource(xsltRdr); </li></ul><ul><li>// Create an XSLTResultTarget from a FileOutputStream for the output file. </li></ul><ul><li>FileOutputStream outStm = new FileOutputStream(outFilename); </li></ul><ul><li>XSLTResultTarget out = new XSLTResultTarget(outStm); </li></ul><ul><li>// Transform the XML in the item, using the xslt object, to the output object. </li></ul><ul><li>xmlItem.transformXML(xslt, out); </li></ul><ul><li>} </li></ul>
    • 23. Demo 1: Sample Updates.dxl <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul><ul><li><!DOCTYPE database SYSTEM &quot;xmlschemas/domino_6_5.dtd&quot;> </li></ul><ul><li>< database xmlns=&quot;http://www.lotus.com/dxl&quot; version=&quot;6.0&quot;> </li></ul><ul><li>< document > </li></ul><ul><li><noteinfo unid =&quot; 5B4B18957C93FA5E85256DF8005B8D17 &quot;/> </li></ul><ul><li>< item name=&quot; shipping &quot;><number> 4.90 </number></item> </li></ul><ul><li></document> </li></ul><ul><li>< document > </li></ul><ul><li><noteinfo unid =&quot; 31D95736B4AC17F985256E000055258D &quot;/> </li></ul><ul><li>< item name=&quot; shipping &quot;><number> 6.85 </number></item> </li></ul><ul><li></document> </li></ul><ul><li></database> </li></ul>
    • 24. Demo 1: RateResponse2Document.xsl <ul><li>… </li></ul><ul><li><xsl:template match=&quot;Package&quot;> </li></ul><ul><li><xsl:element name=&quot; document &quot; namespace=&quot;http://www.lotus.com/dxl&quot;> </li></ul><ul><li><xsl:element name=&quot; noteinfo &quot; namespace=&quot;http://www.lotus.com/dxl&quot;> </li></ul><ul><li><xsl:attribute name=&quot; unid &quot;> </li></ul><ul><li><xsl:value-of select=&quot;@ID&quot;/> </li></ul><ul><li></xsl:attribute> </li></ul><ul><li></xsl:element> </li></ul><ul><li><xsl:apply-templates select=&quot;Postage&quot;/> </li></ul><ul><li></xsl:element> </li></ul><ul><li></xsl:template> </li></ul><ul><li><xsl:template match=&quot;Postage&quot;> </li></ul><ul><li><xsl:element name=&quot; item &quot; namespace=&quot;http://www.lotus.com/dxl&quot;> </li></ul><ul><li><xsl:attribute name=&quot; name &quot;>shipping</xsl:attribute> </li></ul><ul><li><xsl:element name=&quot; number &quot; namespace=&quot;http://www.lotus.com/dxl&quot;> </li></ul><ul><li><xsl:value-of select=&quot;text()&quot;/> </li></ul><ul><li></xsl:element> </li></ul><ul><li></xsl:element> </li></ul><ul><li></xsl:template> </li></ul><ul><li>… </li></ul>
    • 25. Demo 2: XSL:FO and PDF <ul><li>XSL:FO (Formatting Objects) describes the visual layout of a document in XML </li></ul><ul><li>PDF (Portable Document Format) is a widely used document format on the Web </li></ul><ul><li>Various utilities are available to translate from XSL:FO to PDF (and other formats) </li></ul><ul><li>Domino DXL and XSLT support is used to generate a PDF report from selected Domino documents </li></ul>
    • 26. Demo 2: XSL:FO and PDF DXL Exporter FOP (Apache) Domino Order documents XSLT Processor Orders2FO XSL orders.pdf orders.fo DXL documents
    • 27. Demo 2: Code Summary <ul><li>CreatePDFReport agent (LotusScript) </li></ul><ul><li>ExportAndTransform subroutine in ls2004 script library runs NotesDXLExporter and NotesXSLTransformer in a pipeline; result is XSL:FO document in C: mporders.fo </li></ul><ul><li>Transform used is orders2fo.xsl in Stylesheets view </li></ul><ul><li>RunProgramMin subroutine in ls2004 script library translates this using FOP (Apache Formatting Objects Processor); result is PDF document in C: mporders.pdf </li></ul><ul><li>PDF document is automatically displayed </li></ul>
    • 28. Demo 2: CreatePDFReport agent <ul><li>Sub Initialize </li></ul><ul><li>Dim session As New NotesSession </li></ul><ul><li>Dim db As NotesDatabase </li></ul><ul><li>Set db = session.CurrentDatabase </li></ul><ul><li>Call ExportAndTransform(db.UnprocessedDocuments, &quot;orders2fo.xsl&quot;, &quot;c: mporders.fo&quot;) </li></ul><ul><li>Call RunProgramMin(&quot;PDF COMPOSER&quot;, &quot;c: mp&quot;, &quot;-fo orders.fo&quot;, &quot;-pdf orders.pdf&quot;) </li></ul><ul><li>Call RunProgramMax(&quot;PDF READER&quot;, &quot;c: mp&quot;, &quot;orders.pdf&quot;, &quot;&quot;) </li></ul><ul><li>End Sub </li></ul>
    • 29. Demo 2: ExportAndTransform <ul><li>Sub ExportAndTransform(collection As NotesDocumentCollection, stylesheet As String, outputFile As String) </li></ul><ul><li>Dim session As New NotesSession </li></ul><ul><li>Dim exporter As NotesDXLExporter </li></ul><ul><li>Dim xslt As NotesXSLTransformer </li></ul><ul><li>Dim ostream As NotesStream </li></ul><ul><li>' Create DXLO->XSLT->File pipeline that processes the specified collection </li></ul><ul><li>Set exporter = session.CreateDXLExporter(collection) </li></ul><ul><li>exporter.OutputDOCTYPE = False </li></ul><ul><li>Set xslt = session.CreateXSLTransformer(exporter, GetStylesheet(stylesheet)) </li></ul><ul><li>Set ostream = session.CreateStream </li></ul><ul><li>ostream.Open (outputFile) </li></ul><ul><li>ostream.Truncate </li></ul><ul><li>Call xslt.SetOutput(ostream) </li></ul><ul><li>' Run the pipeline </li></ul><ul><li>On Error Goto errh </li></ul><ul><li>exporter.Process </li></ul><ul><li>… </li></ul><ul><li>End Sub </li></ul>
    • 30. Demo 2: Sample orders.fo fragment <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> </li></ul><ul><li>< fo:root xmlns:fo=&quot;http://www.w3.org/1999/XSL/Format&quot; xmlns:dxl=&quot;http://www.lotus.com/dxl&quot;> </li></ul><ul><li>< fo:layout-master-set > </li></ul><ul><li><fo:simple-page-master margin-right=&quot;1in&quot; margin-left=&quot;1in&quot; ... master-name=&quot;first&quot;> </li></ul><ul><li><fo:region-body region-name=&quot;body&quot;/> </li></ul><ul><li></fo:simple-page-master> </li></ul><ul><li>< /fo:layout-master-set > </li></ul><ul><li>< fo:page-sequence master-reference=&quot;first&quot;> </li></ul><ul><li>< fo:flow flow-name=&quot;body&quot;> </li></ul><ul><li>< fo:block ... color=&quot;blue&quot;>Order: 10092919922 < /fo:block > </li></ul><ul><li>< fo:block ... font-weight=&quot;bold&quot;>date: 20031006 < /fo:block > </li></ul><ul><li>... </li></ul><ul><li>< /fo:flow > </li></ul><ul><li>< /fo:page-sequence > </li></ul><ul><li>< /fo:root > </li></ul>
    • 31. Demo 2: orders2fo.xsl fragment <ul><li><xsl:template match=&quot;dxl:item&quot;> </li></ul><ul><li><xsl:choose> </li></ul><ul><li><xsl:when test=&quot;@name = 'total' or @name = 'shipping'&quot; > </li></ul><ul><li><xsl:call-template name=&quot;currencyfield&quot;> </li></ul><ul><li><xsl:with-param name=&quot;name&quot; select=&quot;@name&quot; /> </li></ul><ul><li><xsl:with-param name=&quot;value&quot;> </li></ul><ul><li><xsl:value-of select=&quot;.&quot;/> </xsl:with-param> </li></ul><ul><li></xsl:call-template> </li></ul><ul><li></xsl:when> </li></ul><ul><li><xsl:otherwise> </li></ul><ul><li><xsl:call-template name=&quot;field&quot;> </li></ul><ul><li><xsl:with-param name=&quot;name&quot; select=&quot;@name&quot; /> </li></ul><ul><li><xsl:with-param name=&quot;value&quot;> </li></ul><ul><li><xsl:value-of select=&quot;.&quot;/> </xsl:with-param> </li></ul><ul><li></xsl:call-template> </li></ul><ul><li></xsl:otherwise> </li></ul><ul><li></xsl:choose> </li></ul><ul><li></xsl:template> </li></ul>
    • 32. Demo 2: RunProgram <ul><li>Sub RunProgram (description As String, wdir As String, </li></ul><ul><li>Arg1 As String, Arg2 As String, mode As Integer) </li></ul><ul><li>... </li></ul><ul><li>Set db = session.currentdatabase </li></ul><ul><li>Set view = db.getView (&quot;Programs&quot;) </li></ul><ul><li>Set doc = view.getDocumentByKey(description) </li></ul><ul><li>programName = doc.GetItemValue(&quot;program&quot;) </li></ul><ul><li>fullProgramName = programName(0) & &quot; &quot; & Arg1 & &quot; &quot; & Arg2 </li></ul><ul><li>Chdir wdir </li></ul><ul><li>result = Shell (fullProgramName, mode) </li></ul><ul><li>End Sub </li></ul>
    • 33. Demo 3: OpenOffice Spreadsheet <ul><li>OpenOffice is an open-source, multi-platform office productivity suite </li></ul><ul><ul><li>OpenOffice data is natively stored in XML </li></ul></ul><ul><ul><li>“ subdocument format” of OpenOffice file used in demo is a zip file of 4 .xml files – meta, styles, content, and settings </li></ul></ul><ul><ul><ul><li>demo assumes pre-existing document and only modifies content.xml </li></ul></ul></ul><ul><li>Domino DXL and XSLT support is used to export to a spreadsheet, modify some data, and import back into Domino </li></ul>
    • 34. Demo 3: OpenOffice Spreadsheet DXL Exporter DXL Importer XSL Transformer ZIP UNZIP update/ create mode Edit existing orders or create new orders Domino Order documents DXL docs O2S XSL S2O XSL content .xml orders.sxc
    • 35. Demo 3: Code Summary <ul><li>ExportToSpreadsheet agent (LotusScript) </li></ul><ul><li>ExportAndTransform subroutine runs DXL Exporter and XSL Transformer (with orders2spreadsheet.xsl) yielding C: mpcontent.xml (content portion of OpenOffice file) </li></ul><ul><li>Zip utility replaces content.xml in content.sxc, which can then be edited using OpenOffice </li></ul><ul><li>ImportFromSpreadsheet agent (LotusScript) </li></ul><ul><li>Unzip utility extracts content.xml from content.sxc </li></ul><ul><li>Transformer (with spreadsheet2orders.xsl) creates DXL </li></ul><ul><li>DXL is processed with NotesDOMParser to add unids </li></ul><ul><li>DXL Importer updates/creates order documents </li></ul>
    • 36. Demo 3: ExportToSpreadsheet <ul><li>Sub Initialize </li></ul><ul><li>Dim session As New NotesSession </li></ul><ul><li>Dim db As NotesDatabase </li></ul><ul><li>Set db = session.CurrentDatabase </li></ul><ul><li>Call ExportAndTransform(db.UnprocessedDocuments, &quot;orders2spreadsheet.xsl&quot;, &quot;c: mpcontent.xml&quot;) </li></ul><ul><li>Call RunProgramMin(&quot;ZIP&quot;, &quot;c: mp&quot;, &quot;orders.sxc&quot;, &quot;content.xml&quot;) </li></ul><ul><li>Call RunProgramMax(&quot;SPREADSHEET&quot;, &quot;c: mp&quot;, &quot;orders.sxc&quot;, &quot;&quot;) </li></ul><ul><li>End Sub </li></ul>
    • 37. Demo 3: Sample content.xml fragment <ul><li>< office:document-content … > </li></ul><ul><li>… </li></ul><ul><li>< office:body > </li></ul><ul><li>< table:table table:name=&quot;Sheet1&quot;> </li></ul><ul><li>< table:table-column … /> </li></ul><ul><li>… </li></ul><ul><li>< table:table-row > </li></ul><ul><li>… </li></ul><ul><li>< table:table-cell table:value-type=&quot;currency&quot; table:currency=&quot;USD&quot; table:value=&quot; 6.85 &quot;/> </li></ul><ul><li></ table:table-row > </li></ul><ul><li></ table:table > </li></ul><ul><li></ office:body > </li></ul><ul><li></ office:document-content > </li></ul>
    • 38. Demo 3: orders2spreadsheet.xsl fragment <ul><li><xsl:template match=&quot;dxl:database&quot;> </li></ul><ul><li>< office:document-content office:class=&quot;spreadsheet&quot; office:version=&quot; 1.0 &quot;> </li></ul><ul><li>… </li></ul><ul><li>< office:body > </li></ul><ul><li>< table:table table:name=&quot;Sheet1&quot;> </li></ul><ul><li><!-- Insert the header row   --> </li></ul><ul><li>… </li></ul><ul><li><xsl:apply-templates select=&quot;dxl:document&quot; /> </li></ul><ul><li>< /table:table > </li></ul><ul><li>< /office:body > </li></ul><ul><li>< /office:document-content > </li></ul><ul><li></xsl:template> </li></ul>
    • 39. Demo 3: ImportFromSpreadsheet agent <ul><li>Sub Initialize </li></ul><ul><li>… </li></ul><ul><li>Set xslt = session.CreateXSLTransformer(istream, GetStylesheet(&quot;spreadsheet2orders.xsl&quot;)) </li></ul><ul><li>Set parser = session.CreateDOMParser(xslt) </li></ul><ul><li>Set importer = session.CreateDXLImporter(parser, db) </li></ul><ul><li>importer.DocumentImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE </li></ul><ul><li>importer.ReplicaRequiredForReplaceOrUpdate = False </li></ul><ul><li>On Event PostDOMParse From parser Call processTree </li></ul><ul><li>' Run the pipeline </li></ul><ul><li>On Error Goto errh </li></ul><ul><li>xslt.Process </li></ul><ul><li>… </li></ul><ul><li>End Sub </li></ul>
    • 40. Demo 3: processTree <ul><li>Sub processTree (parser As NotesDOMParser) </li></ul><ul><li>... </li></ul><ul><li>' Walk all documents in the tree and insert UNID attrs based on orderid </li></ul><ul><li>Set documents = parser.Document.GetElementsByTagName(&quot;document&quot;) </li></ul><ul><li>For i = 1 To documents.NumberOfEntries </li></ul><ul><li>' Lookup <item> with name='orderid' and get orderid value </li></ul><ul><li>... </li></ul><ul><li>' Lookup document by orderid </li></ul><ul><li>Set doc = view.GetDocumentByKey(orderid) </li></ul><ul><li>' If found then add a <noteinfo> child element with the unid to docEl </li></ul><ul><li>If Not doc Is Nothing Then </li></ul><ul><li>Set el = parser.Document.CreateElementNode(&quot;noteinfo&quot;) </li></ul><ul><li>Call el.SetAttribute(&quot;unid&quot;, doc.UniversalID) </li></ul><ul><li>... </li></ul><ul><li>End If </li></ul><ul><li>Next </li></ul><ul><li>' Write the DOM tree to the parser's output object </li></ul><ul><li>parser.Serialize </li></ul><ul><li>End Sub </li></ul>
    • 41. Demo 3: spreadsheet2orders.xsl fragment <ul><li><xsl:variable name=&quot;SheetName&quot;>Sheet1</xsl:variable> </li></ul><ul><li><xsl:template match=&quot;office:document-content&quot;> </li></ul><ul><li>< database version=&quot;7.0&quot;> </li></ul><ul><li><!-- Map each row in the table to a document --> </li></ul><ul><li><xsl:apply-templates select=&quot;office:body/table:table[@table:name = $SheetName]/table:table-row[position() > 1]&quot;/> </li></ul><ul><li>< /database > </li></ul><ul><li></xsl:template> </li></ul><ul><li><xsl:template match=&quot;table:table-row&quot;> </li></ul><ul><li>< document form=&quot;Order&quot;> </li></ul><ul><li><xsl:apply-templates select=&quot;table:table-cell[position() &lt; 8]&quot;/> </li></ul><ul><li>< /document > </li></ul><ul><li></xsl:template> </li></ul>
    • 42. Demo 4: Amazon Web Service <ul><li>amazon.com provides a Web service API for searching for product information </li></ul><ul><ul><li>request is made via a standard URL that specifies the parameters of the search </li></ul></ul><ul><ul><li>Amazon Web server answers back with a <ProductInfo> document in XML format </li></ul></ul><ul><li>Domino XSLT and DXL support is used to create a SearchResult document in Domino with a rich, tabular format of the search results </li></ul><ul><ul><li>for simplicity, only the first 10 matches are captured in the results </li></ul></ul>
    • 43. Demo 4: Amazon Web Service Amazon Web service XSLT Processor Keyword Search URL DXL Importer Browse Products dialog Product Info XML ProductInfo 2Document XSL Domino Search Result document DXL Search Result Document
    • 44. Demo 4: Code Summary <ul><li>Search Products agent (Java) </li></ul><ul><li>Builds a request URL from data provided in a Browse Products document (see Java Debug Console for URL) </li></ul><ul><li>URLLoader class from JavaUtilClasses script library loads the URL – response in C: mpSearchResponse.xml </li></ul><ul><li>XSLTTransformer class from JavaUtilClasses transforms response into DXL – see C: mpResponseDocument.dxl </li></ul><ul><li>Transform uses ProductInfo2Document.xsl in Stylesheets view </li></ul><ul><li>DxlImporter is used to create a Domino Search Result document summarizing the search results in a table </li></ul>
    • 45. Demo 4: Search Products agent <ul><li>... </li></ul><ul><li>// Build the request URL. </li></ul><ul><li>url += &quot;http://xml.amazon.com/onca/xml3?t=XYZ&dev-t=&quot;; </li></ul><ul><li>... </li></ul><ul><li>// Load the URL for the rate request and capture the response to a file. </li></ul><ul><li>URLLoader urlLoader = new URLLoader(); </li></ul><ul><li>urlLoader.load(url, searchResponseXmlFile); </li></ul><ul><li>// Transform the response into a DXL document containing the links in a </li></ul><ul><li>// tabular format within rich text. </li></ul><ul><li>XSLTTransformer transformer = new XSLTTransformer(session); </li></ul><ul><li>transformer.transform(searchResponseXmlFile, agentContext.getCurrentDatabase(), productInfo2DocumentXsl, documentDxlFile); </li></ul><ul><li>// Open the DXL file just created. </li></ul><ul><li>Stream dxlStream = session.createStream(); </li></ul><ul><li>dxlStream.open(documentDxlFile); </li></ul><ul><li>// Import the DXL file which will create a new Search Result document. </li></ul><ul><li>Database db = agentContext.getCurrentDatabase(); </li></ul><ul><li>DxlImporter importer = session.createDxlImporter(); </li></ul><ul><li>importer.importDxl(dxlStream, db); </li></ul><ul><li>... </li></ul>
    • 46. Demo 4: Sample URL <ul><li>http://xml.amazon.com/onca/xml3?t=XYZ&dev-t=XXXXXXXXXXXXXX&KeywordSearch= meyers %20 effective &mode= books &type=lite&page=1&f=xml </li></ul>
    • 47. Demo 4: Sample SearchResponse.xml <ul><li>< ProductInfo ...> </li></ul><ul><li><Request> ... </Request> </li></ul><ul><li><TotalResults>10</TotalResults> </li></ul><ul><li><TotalPages>1</TotalPages> </li></ul><ul><li>< Details url=&quot; http://www.amazon.com/exec/obidos/ASIN/... &quot;> </li></ul><ul><li>... </li></ul><ul><li>< ProductName > Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) </ProductName> </li></ul><ul><li><Catalog>Book</Catalog> </li></ul><ul><li><Authors> </li></ul><ul><li>< Author > Scott Meyers </Author> </li></ul><ul><li></Authors> </li></ul><ul><li>... </li></ul><ul><li>< OurPrice > $35.50 </OurPrice> </li></ul><ul><li>... </li></ul><ul><li>< /Details > </li></ul><ul><li>... </li></ul><ul><li>< /ProductInfo > </li></ul>
    • 48. Demo 4: Sample ResponseDocument.dxl <ul><li><document xmlns=&quot;http://www.lotus.com/dxl&quot; version=&quot;6.5&quot; form=&quot;Search Result&quot;> </li></ul><ul><li><item name=&quot;Keywords&quot;><text>meyers effective</text></item> </li></ul><ul><li><item name=&quot;ProductType&quot;><text>books</text></item> </li></ul><ul><li><item name=&quot;SearchResults&quot;> </li></ul><ul><li><richtext> </li></ul><ul><li><pardef keeptogether=&quot;true&quot; keepwithnext=&quot;true&quot; id=&quot;2&quot;/> </li></ul><ul><li><table columnspacing=&quot;0.1000in&quot; rowspacing=&quot;0.0500in&quot; widthtype=&quot;fitmargins&quot;> </li></ul><ul><li><tablecolumn width=&quot;55%&quot;/> </li></ul><ul><li><tablecolumn width=&quot;45%&quot;/> </li></ul><ul><li><tablecolumn width=&quot;0.75in&quot;/> </li></ul><ul><li>... </li></ul><ul><li><tablerow> </li></ul><ul><li><tablecell> </li></ul><ul><li><par def=&quot;2&quot;> </li></ul><ul><li><urllink href= &quot;http://www.amazon.com/exec/obidos/ASIN/...&quot; > </li></ul><ul><li><run><font color=&quot;system&quot;/> Effective C++: 50 Specific Ways to Improve Your Programs and Design (2nd Edition) </run> </li></ul><ul><li></urllink> </li></ul><ul><li></par> </li></ul><ul><li></tablecell> </li></ul><ul><li>... </li></ul><ul><li></document> </li></ul>
    • 49. Demo 4: ProductInfo2Document.xsl fragment <ul><li><xsl:template match=&quot;Details&quot;> </li></ul><ul><li><xsl:element name=&quot; tablerow &quot; xmlns=&quot; http://www.lotus.com/dxl &quot;> </li></ul><ul><li>  <xsl:apply-templates select=&quot;ProductName|Manufacturer|OurPrice&quot; /> </li></ul><ul><li>  </xsl:element> </li></ul><ul><li></xsl:template> </li></ul><ul><li><!-- Map the product name to a URL link which links to the product info.   --> </li></ul><ul><li><xsl:template match=&quot;ProductName&quot;> </li></ul><ul><li><xsl:element name=&quot; tablecell &quot; xmlns=&quot; http://www.lotus.com/dxl &quot;> </li></ul><ul><li>< par def=&quot; 2 &quot;> </li></ul><ul><li><xsl:element name=&quot; urllink &quot; xmlns=&quot; http://www.lotus.com/dxl &quot;> </li></ul><ul><li><xsl:attribute name=&quot; href &quot;> </li></ul><ul><li><xsl:value-of select=&quot;../@url&quot; /> </li></ul><ul><li></xsl:attribute> </li></ul><ul><li>< run > </li></ul><ul><li>< font color=&quot;system&quot; /> </li></ul><ul><li>  <xsl:value-of select=&quot;text()&quot; /> </li></ul><ul><li>  </run> </li></ul><ul><li>  </xsl:element> </li></ul><ul><li>  </par> </li></ul><ul><li>  </xsl:element> </li></ul><ul><li></xsl:template> </li></ul>
    • 50. Summary <ul><li>DXL was used to integrate with several applications </li></ul><ul><ul><li>Made possible by the wide use of XML as a standard data format </li></ul></ul><ul><li>XSLT was a central player because it is a powerful tool for transforming XML </li></ul><ul><ul><li>Also possible to use DOM or SAX parsers or to process XML directly </li></ul></ul><ul><li>Java examples illustrated the Item.transformXML method and the DxlImporter class </li></ul><ul><li>LotusScript examples showed the NotesDXLExporter, NotesXSLTransformer, NotesDOMParser, and NotesDXLImporter classes </li></ul><ul><li>DXL is a powerful integration tool </li></ul>
    • 51. Q & A <ul><li>[email_address] </li></ul><ul><li>Use the Notes/Domino forum to exchange ideas </li></ul><ul><ul><li>Uses of DXL </li></ul></ul><ul><ul><li>Things you’d like to see demoed in the future </li></ul></ul><ul><ul><li>DXL and XML features you’d like to see in Notes/Domino </li></ul></ul><ul><ul><li>Problems and workarounds </li></ul></ul><ul><ul><li>Etc. </li></ul></ul>

    ×