Implementing Smart Paste for my own document type

Post here questions and problems related to oXygen frameworks/document types.
Posts: 22

Implementing Smart Paste for my own document type

Wed Sep 11, 2013 8:25 am

Hi guys,

I have my own document type (based on an XSD schema); the schema includes html-style formatting tags for lists, bold, italics, paragraphs and such.

I'd like to implement smart paste so that docs from Word can retain this kind of formatting, but I'm not clear on whether I need to implement AuthorSchemaAwareEditingHandlerAdapter, or if there is a non-Java way of doing that? Maybe tweaks in the schema to allow the existing smart paste implementation to work?

Any lead / example / code sample welcome.

Thanks a lot,

Posts: 22

Re: Implementing Smart Paste for my own document type

Wed Sep 11, 2013 8:27 am

I forgot to mention that my schema aware preferences do have smart paste enabled, but it's not pasting smartly into my doc :-)
Posts: 5987

Re: Implementing Smart Paste for my own document type

Wed Sep 11, 2013 9:58 am

Hi Yannick,

You would need to also write some Java code to handle this.

First of all, smart paste is based on the fact than when you copy content in an application like MS Word it also sets in the clipboard an HTML translation of the copied content. So Oxygen actually interprets this HTML content from the clipboard using XSLT stylesheets to convert it to its target XML vocabulary.

Let's discuss for example how smart pasting works in XHTML document type for example (as it is probably closer to what you need).
If in the Oxygen Preferences->Document Type Association page you edit the XHTML document type, in the Classpath list there are references to the xhtml.jar containing Java extensions and to a resources folder containing the XSLT stylesheets which are used for conversion. In the same dialog in the XHTMLExtensionsBundle tab there is an extension configured called XHTMLExtensionsBundle which is implemented in the xhtml.jar.

If you download our Author SDK:

you will have in it the Java code for the XHTMLExtensionsBundle implementation.
That code instantiates a class called XHTMLExternalObjectInsertionHandler for which Java sources are also present. On the method XHTMLExternalObjectInsertionHandler.getImporterStylesheetFileName(AuthorAccess) the code returns xhtml2xhtml.xsl which means that this XSLT:


will be called to process the HTML content set in the clipboard by MS Word and return the translated XML content to be inserted at the caret position in the Author mode.

Radu Coravu
<oXygen/> XML Editor

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests