Skip to main content

How to enable copy / paste from Microsoft Office

In this chapter you will learn how to create the XSL transformation to match the elements from your types.js to the elements that can occur in Microsoft Office files.

The goal is that Xeditor automatically creates the correct XML element and copies the content from e.g. Microsoft Word in there.

One of Xeditors features is support for pasting MS Word content. Xeditor will adapt your original Word structure to the one used by your schema. For example, if you paste a list from MS Word into Xeditor, Xeditor will map this to your schema and insert the corresponding list (XML-) structure. For this, there's an additional transformation file, pastetoeditorfirst.xsl, that needs to be adapted to your schema.

The transformation file contains templates matching to the most commonly used MS Word formats (like headings, lists, common inline formats, etc.) and already contains commands creating the corresponding Xeditor elements. All you have to do is fill out the element names as stated by the comments above them. The templates will look something like this:

<xsl:template match="paste/div | paste/span">
<!-- paragraph element type -->
<div data-type="">
<xsl:apply-templates select="br | sub | sup | a | b | strong | i | u | span | text() | ./*[not(self::sub | self::sup | self::a | self::b | self::strong | self::i | self::u | self::span)]//text()"/>
</div>
</xsl:template>

As stated by the comment, the data-type attribute has to be set to the name of the paragraph element used by your schema. Basically the mapping is done by going through the file pastetoeditorfirst.xsl and fill all the data-type attributes as stated by the comments.

For more information read here.