XMetaL Tips and Tricks

XMetaL Community Forum XMetaL Tips and Tricks Script Example: Send XML Source as Outlook Email

  • Derek Read

    Script Example: Send XML Source as Outlook Email

    Participants 0
    Replies 1
    Last Activity 11 years, 11 months ago

    Products: XMetaL Author (Enterprise and Essential)
    Tested with XMetaL Author Enterprise 6.0.1.030

    Request:
    Get XMetaL Author to put HTML that includes syntax highlighting a la Plain Text view onto the Windows clipboard so that when this text is pasted into an application that supports HTML the colouring is retained. Currently, XMetaL just puts the XML on the clipboard as text. Well, I have yet to figure out how to do that…however, I can generate an HTML formatted email directly in Outlook which is what this script demonstrates.

    Requirements:
    XMetaL Author (Essential or Enterprise)
    Microsoft Outlook

    What it Does:
    Takes the XML for the current document and generates HTML that includes styling for colour (thanks in large part to an XSLT created by Oliver Becker) that, when viewed in a browser, looks sort of like XMetaL's Plain Text view syntax highlighting. It then creates a new email message in Microsoft Outlook containing the nicely styled HTML.

    Legal:
    * Licensed Materials – Property of JustSystems, Canada, Inc.
    *
    * (c) Copyright JustSystems Canada, Inc. 2010
    * All rights reserved.
    *
    *——————————————————————-
    * The sample contained herein is provided to you “AS IS”.
    *
    * It is furnished by JustSystems Corporation as a simple example and has not been
    * thoroughly tested under all conditions. JustSystems Canada, Inc., therefore, cannot
    * guarantee its reliability, serviceability or functionality.
    *
    * This sample may include the names of individuals, companies, brands and products
    * in order to illustrate concepts as completely as possible. All of these names are
    * fictitious and any similarity to the names and addresses used by actual persons or
    * business enterprises is entirely coincidental.
    *———————————————————————

    Installation:

    1) Obtain Oliver Becker's 'XML Verbatim' XSLT from his website: [url=http://www2.informatik.hu-berlin.de/~obecker/XSLT/xmlverbatim/xmlverbatim.xsl]xmlverbatim.xsl[/url]

    2) Open the XSLT in a text editor and find the following section:
    [code]
      

      
         
      

      
      
          
          
             converted by xmlverbatim.xsl 1.1, (c) O. Becker
          

          
         

            
               
            

         

         
      
    [/code]

    3 *Change the so the select statement's value is "true()" and not "false()". This should cause line breaks to look fairly similar to what is in the original XML.

    4) Optional: *Comment out the that gives credit to O. Becker in the XML tranformed source (the HTML output). You may not want that appearing in every email you send as it is not part of your original XML source.

    5) *Include the following CSS just before the opening

    tag.
    [code]
         

    [/code]

    6) After you have edited the XSLT file (steps 3,4,5) save the XSLT here with this file name: AuthorStartupxmlverbatim_modified.xsl. You don't need the original xmlverbatim.xsl anymore, but keeping it around won't hurt anything.

    7) Download the file demo_sendingOutlookEmail.zip attached to this posting, unzip the MCR file it contains and place that in the same Startup folder.

    8) Restart XMetaL Author if it is already running, otherwise just start it up.

    9) Optional: Launch Microsoft Outlook. Having it running will speed things up a little bit.

    10) Open an XML document in XMetaL Author in Tags On or Normal view.

    11) From the Macros toolbar run the macro called “Send XML Source as Outlook Email”.

    12) Optional: Modify the XSLT and/or MCR to add new capabilities, change CSS colours or styling, add the macro to a menu or toolbar, etc.

    13) NOT Optional: Test thoroughly before distributing to others in your organization.

    *See xslt_Changes.gif (attached) for required and optional XSLT changes.

    Note: Mr. Becker's XSLT has some licensing around it. If this is for internal use at your organization that may not be an issue (may depend on your location, company policy, and the actual licensing itself). However, if you are an XMetaL partner, or will otherwise be sharing the work you do with this code (selling it as part of services work, etc) you should look into the legalities of doing so. I believe Mr. Becker mentions he is allowing LGPL usage which is pretty much “free for any use” as it gets.

    Reply

    LeeHart

    Reply to: Script Example: Send XML Source as Outlook Email

    Wow, that's a big step towards what we're looking for. We'd need to get approval from our lawyers before using that XSLT; a solution that's part of XMetaL would be more useful.

    Thanks!

    Lee

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support