Successfully reported this slideshow.
Your SlideShare is downloading. ×

AD215 - Practical Magic with DXL

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 51 Ad

More Related Content

Slideshows for you (20)

Similar to AD215 - Practical Magic with DXL (20)

Advertisement

Recently uploaded (20)

Advertisement

AD215 - Practical Magic with DXL

  1. 2. Practical Magic with DXL <ul><ul><li>Stephan H. Wissel, Lotus Technology & Productivity Advisor, IBM Techworks AP </li></ul></ul>AD215
  2. 5. Agenda <ul><li>What is DXL? </li></ul><ul><li>Tools around DXL </li></ul><ul><li>What can I do with DXL? </li></ul><ul><li>Q & A </li></ul>
  3. 6. What is DXL? <ul><li>Representation of Note elements in XML </li></ul><ul><li>First occurrence in R5 XML toolkit </li></ul><ul><li>Constantly expanding </li></ul><ul><li>Schema is available in <notesprogramdir>/xmlschemas </li></ul><ul><ul><li>domino_6_0.xsd, domino_7_0_M3.xsd, domino_8_0_2.xsd, domino_8_0.xsd, domino_7_0_1.xsd, domino_7_0_M4.xsd, domino_8_0_M2.xsd, domino_8_5_M1.xsd, domino_7_0_2.xsd, domino_7_0_M6.xsd, domino_8_0_M3.xsd, domino_8_5_M2.xsd, domino_7_0_3.xsd, domino_7_0.xsd, domino_8_0_M4.xsd domino_8_5.xsd, domino_7_0_M2.xsd, domino_8_0_1.xsd, domino_8_0_M5.xsd </li></ul></ul><ul><li>Comes with helper classes </li></ul><ul><ul><li>DXLExporter, NotesDXLExporter </li></ul></ul><ul><ul><li>DXLImporter, NotesDXLImporter </li></ul></ul>
  4. 7. DXL Use Design Data
  5. 8. DXL Usage pattern
  6. 9. DXL Usage pattern
  7. 10. DXL Usage pattern
  8. 11. Tools around DXL <ul><li>LotusScript & Java Classes </li></ul><ul><ul><li>DXL Importer </li></ul></ul><ul><ul><li>DXL Exporter </li></ul></ul><ul><ul><li>NotesStream, DOMBrowser </li></ul></ul><ul><li>XSLT, XPath </li></ul><ul><li>Code Snippets </li></ul><ul><li>DXL Peek (OpenNTF.org) </li></ul><ul><li>DXL Explorer (domiclipse.com) </li></ul><ul><li>DXL Studio </li></ul>
  9. 12. Exporting a whole database design (Java Edition) <ul><li>NotesSession s = NotesFactory.createSession(); </li></ul><ul><li>Database db = s.getDatabase(“YourServer”, “YourDB.nsf”); </li></ul><ul><li>NoteCollection nc = db.createNoteCollection(false); </li></ul><ul><li>nc.selectAllNotes(true); // We select everything </li></ul><ul><li>nc.selectAllDataNotes(false); // And de-select the data </li></ul><ul><li>nc.buildCollection(); </li></ul><ul><li>DxlExporter exporter = s.createDxlExporter(); </li></ul><ul><li>exporter.setExitOnFirstFatalError(false); // continue on problems </li></ul><ul><li>exporter.setOmitMiscFileObjects(true); </li></ul><ul><li>exporter.setForceNoteFormat(false); </li></ul><ul><li>// We omit the DocType to make sure XSLT doesn't complain </li></ul><ul><li>exporter.setOutputDOCTYPE(false); </li></ul><ul><li>String result = exporter.exportDxl(nc); </li></ul><ul><li>Writer out = new OutputStreamWriter(new FileOutputStream( </li></ul><ul><li>“yourfile.dxl”), &quot;UTF-8&quot; ); out.write(output); out.close(); </li></ul>
  10. 13. Caveats <ul><li>exporterSetForceNoteFormat(true/false) </li></ul><ul><ul><li>False exports forms/views as <form ..../> <view ..../> </li></ul></ul><ul><ul><li>True exports forms/views as <note type=”form” ... /> <note type=”view” .../> </li></ul></ul><ul><ul><li>You need different transformation strategies for both </li></ul></ul><ul><ul><li>TRUE = roundtrip save (mostly) </li></ul></ul><ul><ul><li>FALSE = more manipulation possibilities, smaller, crashes sometimes </li></ul></ul><ul><li>OutputStreamWriter(OutputStream, “UTF-8”) </li></ul><ul><ul><li>Writing directly to OutputStream is faster but format is anybody's guess </li></ul></ul><ul><ul><li>Using OutputStreamWriter you can force UTF-8 </li></ul></ul><ul><ul><li>Big issue when chaining in LotusScript </li></ul></ul><ul><li>Still work in progress </li></ul>
  11. 14. Importing Design back into Notes (LotusScript) <ul><li>Public Sub ImportDesignDXL(targetDB As NotesDatabase, newDXL As String) </li></ul><ul><ul><li>Dim s As New NotesSession </li></ul></ul><ul><ul><li>Dim importer As NotesDXLImporter </li></ul></ul><ul><ul><li>Set importer = s.CreateDXLImporter 'Create the importer </li></ul></ul><ul><ul><li>importer.ACLImportOption = DXLIMPORTOPTION_IGNORE </li></ul></ul><ul><ul><li>importer.CompileLotusScript = False 'We deal with Script later </li></ul></ul><ul><ul><li>importer.DesignImportOption = DXLIMPORTOPTION_REPLACE_ELSE_CREATE </li></ul></ul><ul><ul><li>importer.DocumentImportOption = DXLIMPORTOPTION_IGNORE </li></ul></ul><ul><ul><li>importer.ExitOnFirstFatalError = False </li></ul></ul><ul><ul><li>importer.ReplaceDBProperties = True 'We also update DB properties </li></ul></ul><ul><ul><li>importer.ReplicaRequiredForReplaceOrUpdate = False </li></ul></ul><ul><ul><li>importer.UnknownTokenLogOption = DXLLOGOPTION_WARNING </li></ul></ul><ul><ul><li>Call importer.Import(newDXL, targetDB) 'Execute the import </li></ul></ul><ul><ul><li>Msgbox(importer.log) </li></ul></ul><ul><li>End Sub </li></ul>
  12. 15. Caveats <ul><li>DXLImporter.setInput(NotesSteam) </li></ul><ul><ul><li>File Format must be proper UTF-8 </li></ul></ul><ul><ul><li>Required for large data </li></ul></ul><ul><li>Format Fidelity </li></ul><ul><ul><li>Constantly improving </li></ul></ul><ul><ul><li>Use the latest importer </li></ul></ul><ul><li>Some properties don't make sense in an import </li></ul><ul><ul><li>wasupdatedby </li></ul></ul><ul><ul><li>noteinfo * </li></ul></ul><ul><li>Be careful with the auto-formatter in your XML editor </li></ul>noteinfo/@unid is needed for design replace!
  13. 16. Manipulate DXL <ul><li>Iterate through the DOM until you hit what you are looking for </li></ul><ul><li>Use XPath expressions to find the element(s) </li></ul><ul><ul><li>/database/form[@name='Memo'] </li></ul></ul><ul><ul><li>//column[@categorized='true'] </li></ul></ul><ul><ul><li>//field[@name='Subject'] </li></ul></ul><ul><li>This is a good time to brush up your Java Skills*! </li></ul><ul><ul><li>For the die hard LotusScript developers: </li></ul></ul><ul><ul><ul><li>www.nsftools.com/tips/XmlNodeReader/ </li></ul></ul></ul><ul><ul><ul><li>www-10.lotus.com/ldd/bpmpblog.nsf/dx/dom-for-output?opendocument </li></ul></ul></ul>* or borrow other peoples code!
  14. 17. Manipulate DXL <ul><li>USE XSLT to change DXL values </li></ul><ul><li>Use XPath expressions (again) to find the element(s) </li></ul><ul><li><xsl:template match=”/d:database/d:view/d:column/d:columnheader/d:font”> <d:font size=”10px” /> </xsl:template> </li></ul><ul><ul><li>Unifies all column header fonts to default font 10px size </li></ul></ul><ul><li><xsl:template match=” //d:field[@type=&quot;datetime&quot; > <xsl:element name=”field”> <xsl:apply-templates select=”*@ /> <xsl:attribute name=”extrahtmlattrs”> dojoType=”dijit.form.DateTextBox” </xsl:attribute> </xsl:element> </xsl:template> </li></ul><ul><ul><li>Insert a DojoType into every date field </li></ul></ul>
  15. 18. Accessing DXL nodes in Java using XPath <ul><li>public void insertBefore (Document doc, String newXmlContent) { </li></ul><ul><li>DocumentFragment frag = this.parseXml(doc, newXmlContent); </li></ul><ul><li>XPathFactory factory = XPathFactory.newInstance(); </li></ul><ul><li>XPath xpath = factory.newXPath(); </li></ul><ul><li>XPathExpression expr = </li></ul><ul><li>xpath.compile(this.xPathExpression); </li></ul><ul><li>Object exprResult = </li></ul><ul><li>expr.evaluate(doc, XPathConstants.NODESET); </li></ul><ul><li>NodeList nodes = (NodeList) exprResult; </li></ul><ul><li>for (int i = 0; i < nodes.getLength(); i++) { </li></ul><ul><li>Node curNode = nodes.item(i); </li></ul><ul><li>Node parent = curNode.getParentNode(); </li></ul><ul><li>parent.insertBefore(frag, curNode); </li></ul><ul><li>} </li></ul>
  16. 19. Converting a XML String into a NodeFragment <ul><li>private DocumentFragment parseXml(Document doc, String fragment) { </li></ul><ul><li>fragment = &quot;<fragment>&quot;+fragment+&quot;</fragment>&quot;; </li></ul><ul><li>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); </li></ul><ul><li>InputSource source = new InputSource(new StringReader(fragment)); </li></ul><ul><li>Document d = factory.newDocumentBuilder().parse(source); </li></ul><ul><li>Node node = doc.importNode(d.getDocumentElement(), true); </li></ul><ul><li>DocumentFragment docfrag = doc.createDocumentFragment(); </li></ul><ul><li>while (node.hasChildNodes()) { </li></ul><ul><li>docfrag.appendChild(node.removeChild(node.getFirstChild())); </li></ul><ul><li>} </li></ul><ul><li>// Return the fragment </li></ul><ul><li>return docfrag; </li></ul><ul><li>} </li></ul>
  17. 20. A bit messy isn't it? Enter DXLStudio
  18. 21. DXL Studio <ul><li>A collection of Java Classes* to be used in your programs or from the command line: </li></ul><ul><li>DesignExporter [outputpath] [NsfName] [Server] </li></ul><ul><li>DesignImporter [sourcepath] [NsfName] (local only) </li></ul><ul><li>DesignInjector [workfile] [NsfName] </li></ul><ul><li>TransformXML [source] [style] [target] </li></ul><ul><li>DocumentServer [outputpath] [Server] </li></ul><ul><li>DXLStudio.nsf </li></ul>* com.ibm.sg.dxlmagic.*
  19. 22. Using the command line Java tools <ul><li>Copy DXLMagic.jar to <notesprogramdir>vmibxt* </li></ul><ul><li>Edit your CLASSPATH variable (or create one): Windows : CLASSPATH=.;<notesprogramdir> vmibxtotes.jar; <notesprogramdir>vmibxtebsvc.jar; <notesprogramdir>vmibxtXLMagic.jar Linux : CLASSPATH=.:<notesprogramdir>/jvm/lib/ext/Notes.jar; <notesprogramdir>/jvm/lib/ext/websvc.jar; <notesprogramdir>/jvm/lib/ext/DXLMagic.jar </li></ul><ul><li>Run your Notes client </li></ul><ul><li>Run any of the tools: java com.ibm.sg.dxlmagic.<NameOfTheTool> </li></ul><ul><li>Running without parameter gives you a short instruction. </li></ul>* or any other place you can remember
  20. 23. DXLStudio.nsf* * on OpenNTF
  21. 24. You still need to understand XPATH and XSLT
  22. 25. ... more examples <ul><li>/d:database/d:form[@bgcolor] all forms with a background color </li></ul><ul><li>/d:database/d:form//d:font[color=&quot;#f7f7f7&quot;] all font entries in light gray </li></ul><ul><li>/d:database/d:form[not (descendant::table)] forms that don't have tables </li></ul><ul><li>//d:form/d:code[@event=&quot;webqueryopen&quot;] all webqueryopen agent definitions </li></ul><ul><li>//d:form[d:code/@event=&quot;webqueryopen&quot;] all forms with webqueryopen agent definitions </li></ul>
  23. 26. What can I do with DXL <ul><li>Documentation Magic </li></ul><ul><li>Database Magic </li></ul><ul><li>Form Magic </li></ul><ul><li>View Magic </li></ul><ul><li>XPages Magic </li></ul>
  24. 27. Documentation Magic <ul><li>Document your database (= Synapsis Deluxe) </li></ul><ul><ul><li>http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Comprehensive </li></ul></ul><ul><li>Report use of Hide-when formulas </li></ul><ul><li>Usage of fields and formulas </li></ul><ul><li>Inherited design report </li></ul>
  25. 28. Demo
  26. 29. Documentation Magic II <ul><li>Document your database(s) to extract # of design elements </li></ul><ul><li>Down to the LOC level for LotusScript, Java, JavaScript </li></ul><ul><li>Assign LOC equivalents to design artifacts (e.g. A field definition is worth 5 LOC) </li></ul><ul><li>Run a COCOMO II Analysis how much time & $$$ your deployment is worth </li></ul><ul><li>http://www.cms4site.ru/utility.php?utility=cocomoii </li></ul>
  27. 30. java DocumentServer [path] [Servername] java DocumentDesignTags java DocumentDesignMetrics java ExportDesign .csv .metric .metric .metric .metric .metric .dxl .dxl .dxl .dxl .dxl NSF NTF
  28. 31. Let us have a look
  29. 32. Domino 8.5 Templates Figures* <ul><li>> 1,300 forms & subforms </li></ul><ul><li>> 800 views </li></ul><ul><li>> 350 agents </li></ul><ul><li>> 47,000 @formula (in 130,00 lines) </li></ul><ul><li>> 155,00 Lines of LotusScript </li></ul><ul><li>> 44,00 Lines of JavaScript </li></ul><ul><li>Cocomo II Estimate to recreate this: 4.5 years, 273 staff, >200M cost </li></ul>* based on 69 of 89 templates
  30. 33. Database Magic <ul><li>Inject custom code into standard templates </li></ul><ul><li>Cleanup Forms </li></ul><ul><li>Importing forms </li></ul><ul><ul><li>HTML </li></ul></ul><ul><ul><li>ODF </li></ul></ul>
  31. 34. Form Magic <ul><li>Cleanup forms by separating code into libraries </li></ul><ul><li>Adding standard design elements </li></ul>
  32. 35. Demo
  33. 36. View Magic <ul><li>Find views with similar selection formulas </li></ul><ul><li>Unify the look & feel of your views </li></ul><ul><ul><li>http://www.openntf.org/Projects/pmt.nsf/ProjectLookup/Viewnify </li></ul></ul><ul><li>Create the one big view for XPages use </li></ul>
  34. 37. Demo
  35. 38. XPages Magic
  36. 39. Classic Domino -> XPages <ul><li>Forms </li></ul><ul><ul><li>RichText -> XML / xHTML </li></ul></ul><ul><ul><li>@Fomula / LotusScript -> JavaScript </li></ul></ul><ul><ul><li>Tables = Tables </li></ul></ul><ul><ul><li>Forms = Forms </li></ul></ul><ul><ul><li>Fields = Fields </li></ul></ul><ul><ul><li>Fonts = Fonts (or CSS?) </li></ul></ul><ul><li>Views </li></ul><ul><ul><li>$$ViewTemplate -> Xpage </li></ul></ul><ul><ul><li>View -> DataSource </li></ul></ul>
  37. 40. Translate Classic Notes to XPages
  38. 41. Translate Classic Notes to XPages
  39. 42. Translate Classic Notes to XPages
  40. 43. Translate Classic Notes to XPages
  41. 44. Demo
  42. 45. In Summary – What did we see <ul><li>Documentation </li></ul><ul><li>Variation Management </li></ul><ul><li>Code conversion </li></ul>
  43. 46. A few ideas <ul><li>Use a Stylesheet to transform your sample view/XPage/Form into a stylesheet </li></ul><ul><li>Convert a spreadsheet table into an application </li></ul><ul><li>Extract FieldNames and FieldHelp into a HTML form and push the updates back </li></ul><ul><li>Store the DXL in DB/2 PureXML for cross-reference </li></ul><ul><li>Populate “static” keyword fields instead of @DBColumn/@DBLookup </li></ul><ul><li>Change text fields that contain CN=... into names fields </li></ul><ul><li>Add @trim(@thisValue) to all empty text field Input Translations </li></ul><ul><li>Update error messages of Input Validations </li></ul>
  44. 47. Reading Materials <ul><li>XML, XSLT, XPATH </li></ul><ul><ul><li>http://www.w3.org </li></ul></ul><ul><ul><li>http://www.w3schools.com </li></ul></ul><ul><ul><li>http://www.ibm.com/developerworks/library/x-wxxm35.html </li></ul></ul><ul><li>XML and Java </li></ul><ul><ul><li>http://www.xml.com/pub/rg/XML_and_Java_Tutorials </li></ul></ul><ul><ul><li>http://www.exampledepot.com/egs/org.w3c.dom/pkg.html </li></ul></ul><ul><li>DXL </li></ul><ul><ul><li>http://www.ibm.com/developerworks/lotus/library/domino-dxl/ </li></ul></ul><ul><ul><li>http://www.ferdychristant.com/blog/articles/DOMV-674NCF </li></ul></ul>
  45. 48. Books <ul><li>Jeni Tennison </li></ul><ul><ul><li>Beginning XSLT 2.0: From Novice to Professional (Beginning: from Novice to Professional) </li></ul></ul><ul><ul><li>XSLT and XPath On The Edge, Unlimited Edition </li></ul></ul><ul><li>Michael Kay </li></ul><ul><ul><li>XSLT 2.0 and XPath 2.0 Programmer's Reference (Programmer to Programmer) </li></ul></ul><ul><ul><li>XSLT 2.0 Programmer's Reference (Programmer to Programmer) </li></ul></ul><ul><ul><li>XPath 2.0 Programmer's Reference (Programmer to Programmer) </li></ul></ul>
  46. 49. Q & A
  47. 50. <ul><ul><li>[email_address] Twitter:notessensei </li></ul></ul>Thank You!
  48. 51. Legal disclaimer <ul><li>© IBM Corporation 2008. All Rights Reserved. </li></ul><ul><li>The information contained in this publication is provided for informational purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this publication, it is provided AS IS without warranty of any kind, express or implied. In addition, this information is based on IBM’s current product plans and strategy, which are subject to change by IBM without notice. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, this publication or any other materials. Nothing contained in this publication is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. </li></ul><ul><li>References in this presentation to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates. Product release dates and/or capabilities referenced in this presentation may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way. Nothing contained in these materials is intended to, nor shall have the effect of, stating or implying that any activities undertaken by you will result in any specific sales, revenue growth or other results. </li></ul><ul><li>Performance is based on measurements and projections using standard IBM benchmarks in a controlled environment. The actual throughput or performance that any user will experience will vary depending upon many factors, including considerations such as the amount of multiprogramming in the user's job stream, the I/O configuration, the storage configuration, and the workload processed. Therefore, no assurance can be given that an individual user will achieve results similar to those stated here. </li></ul><ul><li>All customer examples described are presented as illustrations of how those customers have used IBM products and the results they may have achieved. Actual environmental costs and performance characteristics may vary by customer. </li></ul><ul><li>IBM, the IBM logo, Lotus, Lotus Notes, Notes, Domino, Quickr, Sametime, WebSphere, UC2, PartnerWorld and Lotusphere are trademarks of International Business Machines Corporation in the United States, other countries, or both. Unyte is a trademark of WebDialogs, Inc., in the United States, other countries, or both. </li></ul><ul><li>Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries. </li></ul><ul><li>Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. </li></ul><ul><li>Microsoft and Windows are trademarks of Microsoft Corporation in the United States, other countries, or both. </li></ul><ul><li>Intel, Intel Centrino, Celeron, Intel Xeon, Intel SpeedStep, Itanium, and Pentium are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. </li></ul><ul><li>UNIX is a registered trademark of The Open Group in the United States and other countries. </li></ul><ul><li>Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. </li></ul><ul><li>Other company, product, or service names may be trademarks or service marks of others. </li></ul><ul><li>All references to ACME Corp refer to a fictitious company and are used for illustration purposes only. </li></ul>

Editor's Notes

×