3. Integrating "Paste from Word" into configurations other than XHTML, DocBook and DITA

We'll explain how to integrate "Paste from Word" into a configuration by using an example. The configuration we'll modify is called "Simple Section (XML Schema)". It is found in xsd_section_config/. This sample configuration is described in Section 2, “A configuration for the "Simple Section" document type.” in XMLmind XML Editor - Configuration and Deployment.

Procedure:

  1. Add a menu item invoking command pasteFromWord.

    Excerpts from samples/xsd_section_config/pfw/pfw.incl:

    <menu label="-" insert="##first">
      <item label="Paste from _Word" 
            icon="paste-from-word:common/paste_from_word.png"
            command="pasteFromWord" 
            parameter="-t section-config:pfw/pfw.xslt"/>
      <separator />
    </menu>
  2. Notice in the above configuration file the parameter of command pasteFromWord which specifies that the "XHTML 1.0 Transitional" document created during phase #2 is to be converted to a "Simple Section" using XSLT 1.0 stylesheet "section-config:pfw/pfw.xslt"[1].

    As you can see, most of the integration effort consists in developing XSLT 1.0 stylesheet "section-config:pfw/pfw.xslt".

    There are few things to say about how to develop this XSLT 1.0 stylesheet:

    • Run toxml with a -t "" option to learn about the XHTML input of the XSLT stylesheet:

      C:\…\paste_from_word> toxml -t "" test1.htm test1.xhtml
    • Read the source of other similar XSLT stylesheets. For example: paste-from-word:xslt/docbook5.xslt, paste-from-word:xslt/topic.xslt, etc.

    • Notice that the XHTML body element is always processed as follows:

      <xsl:template match="h:body">
        <xsl:processing-instruction name="pfw-begin-body"/>
      
        ...
      
        <xsl:processing-instruction name="pfw-end-body"/>
      </xsl:template>

      This is needed for the following reasons:

      • When the user selects menu item "Paste from Word" to replace the root element of her/his document, suffice for command pasteFromWord to paste the root element of the document generated by the XSLT stylesheet.

      • In any other case, command pasteFromWord pastes all the nodes found between <?pfw-begin-body?> and <?pfw-end-body?>.



[1] Location "section-config:pfw/pfw.xslt" can be successfully converted to an URL because xsd_section_config/ contains XML catalog catalog.xml:

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  <rewriteURI uriStartString="section-config:" rewritePrefix="." />
  ...