On 12/16/22 12:01, Madlik, Monika (LNG-VIE) wrote:

I want to paste text from the clipboard as a formatted text, so that i.e. line breaks don’t get lost.

Example:

I copy this text:

Text1

Text2

Text3

And wanted to paste it as:

<absatz>Text1</absatz>

<absatz>Text2</absatz>

<absatz>Text3</absatz>

I wrote the following command:

<cfg:command name="insertAfterAsParagraphs">

<cfg:macro>

                             <cfg:sequence>

                                          <cfg:command name="pasteAs" parameter="after[implicitElement] #template(p,absatz)"/>

                             </cfg:sequence>

               </cfg:macro>

</cfg:command>

The template below is #template(absatz,absatz), not #template(p,absatz).




And I wrote the following element template:

<elementTemplate name="absatz" dynamic="true">

               <absatz>{$line}</absatz>

</elementTemplate>

The namespaces of the above element template are inconsistent. It could be 1 of the following 4 possibilities:

<elementTemplate name="absatz">
  <absatz xmlns="">{$line}</absatz>
</elementTemplate>

<elementTemplate name="absatz>
  <absatz xmlns="YOUR_NAMESPACE_HERE">{$line}</absatz>
</elementTemplate>

<cfg:elementTemplate name="absatz">
  <absatz xmlns="">{$line}</absatz>
</cfg:elementTemplate>

<cfg:elementTemplate name="absatz>
  <absatz xmlns="YOUR_NAMESPACE_HERE">{$line}</absatz>
</cfg:elementTemplate>

Moreover the above element template is NOT dynamic ({$line} is NOT an XPath 1.0 expression). Please remove dynamic="true" and if you want, add more useful selectable="false" (means: not for general use).

See http://www.xmlmind.com/xmleditor/_distrib/doc/configure/elementTemplate.html




But when I copy text from the Internet and want to paste it via defined shortcut, nothing happens.

Aside the 3 above mistakes, it could be anything.

Please add trace="true" to your "insertAfterAsParagraphs" macro. After doing that please start XXE, not the usual way (by double-clicking XXE_install_dir/bin/xxe.exe) but instead 1) by opening a command prompt window and then 2) by executing command XXE_install_dir/bin/xxe-c.bat within the command prompt.

If your macro "insertAfterAsParagraphs" is actually invoked using your shortcut, then you'll see in the command prompt why it fails.






--
XMLmind XML Editor Support List
xmleditor-support@xmlmind.com
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to