XMetaL Tips and Tricks
XMetaL Community Forum › XMetaL Tips and Tricks › Script Example: Send XML Source as Outlook Email
Derek Read July 16, 2010 at 11:11 pm
Script Example: Send XML Source as Outlook EmailJuly 16, 2010 at 11:11 pmParticipants 0Replies 1Last Activity 12 years, 8 months ago
Products: XMetaL Author (Enterprise and Essential)
Tested with XMetaL Author Enterprise 6.0.1.030
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.
XMetaL Author (Essential or Enterprise)
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.
* 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.
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:
converted by xmlverbatim.xsl 1.1, (c) O. Becker
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
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.LeeHart July 17, 2010 at 5:00 am
Reply to: Script Example: Send XML Source as Outlook EmailJuly 17, 2010 at 5:00 am
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.
- You must be logged in to reply to this topic.