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:
xmlverbatim.xsl2) Open the XSLT in a text editor and find the following section:
<xsl:param name="indent-elements" select="false()" />
<xsl:template match="/">
<xsl:apply-templates select="." mode="xmlverb" />
</xsl:template>
<!-- root -->
<xsl:template match="/" mode="xmlverb">
<xsl:text>
</xsl:text>
<xsl:comment>
<xsl:text> converted by xmlverbatim.xsl 1.1, (c) O. Becker </xsl:text>
</xsl:comment>
<xsl:text>
</xsl:text>
<div class="xmlverb-default">
<xsl:apply-templates mode="xmlverb">
<xsl:with-param name="indent-elements" select="$indent-elements" />
</xsl:apply-templates>
</div>
<xsl:text>
</xsl:text>
</xsl:template>
3 *Change the
<xsl:param> 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
<xsl:comment> 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
<div> tag.
<style type="text/css">
.xmlverb-default { color: #000000; background-color: #ffffff; font-family: monospace }
.xmlverb-element-name { color: #FF0000}
.xmlverb-element-nsprefix { color: #FF0000}
.xmlverb-attr-name { color: #FF0000}
.xmlverb-attr-content { color: #0000FF}
.xmlverb-ns-name { color: #FF0000}
.xmlverb-ns-uri { color: #FF0000}
.xmlverb-text { color: #000000}
.xmlverb-comment { color: #990099}
.xmlverb-pi-name { color: #009999}
.xmlverb-pi-content { color: #009999}
</style>
6) After you have edited the XSLT file (steps 3,4,5) save the XSLT here with this file name:
<XMetaL installation path>\Author\Startup\xmlverbatim_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.