Edit online

The Smart Paste feature preserves certain style and structure information when copying content from some of the most common applications and pasting into frameworks (document types) that support Smart Paste in Oxygen XML Author. For other document types, the default behavior of the paste operation is to keep only the text content without the styling.

The style of the pasted content can be customized by editing an XSLT stylesheet for a particular document type (framework). The XSLT stylesheet must accept an XHTML flavor of the copied content as input, and transform it to the equivalent XML markup that is appropriate for the target document type of the paste operation.

How to Customize the Smart Paste Mapping

To customize the mapping between the markup of the copied content and the markup of the pasted content for a particular document type, follow these steps:
  1. Make sure the particular framework contains a folder named resources in the following path structure:

    /frameworks/[Document Type]/resources

  2. Create an XSLT file named xhtml2content.xsl and save it in the resources folder for the particular framework.

    For example: /frameworks/[Document Type]/resources/xhtml2content.xsl

  3. Add your customized styling in the XSLT file. A list of supported parameters can be found in the Supported Parameters for the Custom Smart Paste XSLT section below.
    Tip: The built-in DITA framework includes an xhtml2ditaDriver.xsl file (in [OXYGEN_INSTALL_DIR]/frameworks/dita/resources) that imports various other stylesheets that apply cleanup and handle the conversion from the pasted HTML content to DITA. If you are using a custom extension of the DITA framework, you can copy the entire contents of the built-in dita/resources folder and customize the stylesheets according to your needs.
  4. You can test modifications done in the stylesheet by pasting content without having to restart Oxygen XML Author.

Result: When you paste content from external applications (such as a web browser or and Office document) to a document that is open in Author mode, and that matches the particular framework, the styling from the xhtml2content.xsl stylesheet will be applied on the clipboard contents.

Customized Smart Paste Stylesheet Sample:
<xsl:stylesheet version="1.0"
  exclude-result-prefixes="xsl xhtml">

  <xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>

  <xsl:template match="xhtml:b | xhtml:strong">
    <content styleCode="bold" >
      <xsl:apply-templates select="@* | node()"/>

  <xsl:template match="*">
    <xsl:apply-templates select="@* | node()"/>

  <xsl:template match="@* | node()">
      <xsl:apply-templates select="@* | node()"/>


Supported Parameters for the Custom Smart Paste XSLT

The following parameters can be used in your XSLT stylesheet for customizing the Smart Paste mechanism:

The custom XSLT stylesheet receives this parameter with a value of true if the end-user is pasting content inside a table.
A URL pointing to the folder where the currently edited XML document is located. This is used to save images relative to the current XML document.
A sequence of element names showing the current context in the XML document where the paste occurred.
A sequence of namespaces, one for each context path name.
The separator between the path names. Its value can be used to split the context path names to a sequence.
By default, there is an extra check in place to ensure that the applied XSLT does not remove the original text from the pasted content. If there is a file called externalPasteOptions.xml in the resources folder, you can use it to specify the default behavior for checking if the XSLT stylesheet loses content during conversion:
<!-- Options that control external paste 
(automatic conversions when pasting HTML and URL flavors from the clipboard). -->
	<!--True to check if the entire sequence of words which get pasted are
           converted to the target vocabulary. If the check fails, the content
           will be inserted as a simple sequence of words without any formatting.-->