Please note that this level of support is in principle reserved to our customers. Just to prove our good will, we'll try to answer your questions the best we can. But, unless you become a customer, we are not going to answer further questions like the following ones.


On 04/11/2017 01:41 AM, Ron Van den Branden wrote:

I've recently discovered XMLMind, and am impressed by its customization
possibilities. I'm investigating how it can be used in the short term
for a TEI-based edition project that will involve a text transcription
phase by volunteers. In this context, XMLMind's capabilities for tagless
editing and customized menu buttons are looking very promising.

In order to facilitate the editing experience, I would like to implement
following key bindings:
    -DELETE: IF (caret is at last position and there is a following
sibling element) THEN unwrap following sibling element ELSE
deleteSelectionOrJoinBlockOrDeleteChar
    -BACKSPACE: IF (caret is at first position and there is a preceding
sibling element) THEN unwrap preceding sibling element ELSE
deleteSelectionOrJoinBlockOrDeleteChar

That is: if the caret is right before the <add> element in following
example:

    <p>This is paragraph containing <add>added text with <del>some
deletions</del> as well</add>.</p>

When the user hits the DELETE key, I would like to get following output:

    <p>This is paragraph containing added text with <del>some
deletions</del> as well.</p>

OK, but this is somewhat unusual, e.g. a word processor (most users are familiar with these) won't do something similar. Anyway, your "unwrap" command is indeed useful. See below.




Thanks to the examples, I've been able to figure out immediately how the
keys can be bound to the specific commands. Yet, I'm facing two problems
when implementing the condition in a macro:
    1. How can a condition be specified that tests for the caret
position

Tests whether caret is at the beginning of a text node:

---
<test expression="$dotOffset = 0"/>
---



Tests whether caret is at the end of a text node:

---
<test expression="$dotOffset = string-length(string($dot))"/>
---



and following/preceding sibling?

Out of my head:

---
<test context="$implicitNode"
expression="following-sibling::*[1][self::htm:add or self::htm:del] or preceding-sibling::*[1][self::htm:add or self::htm:del]"/>
---



Reference:

* Macro commands, 1. Reference, http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html

* 1.3 XPath variables, http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html



You may want to use the "Search|Find Element", "Advanced" tab to test all these XPath expressions (XPath 1.0 only please). See http://www.xmlmind.com/xmleditor/_distrib/doc/help/searchMenu.html



    2. How can an unwrap action be defined that preserves any elements
inside the tag to be removed (this means that the "convert to (text)"
function can't be used, since that will convert its content to a string
without further tags.

Parent being already selected. Select all children. Copy all children to clipboard. Select parent. Paste copied children, thus replacing selected parent.

---
    <sequence>
      <command name="selectNode"
               parameter="children[implicitElement]"/>
      <command name="copy" />
      <command name="selectNode"
               parameter="parentOrNode"/>
      <command name="paste"
               parameter="toOrInto"/>
    </sequence>
---

Note that rather than typing what's above, I've just recorded a macro then selected "Tools|Record Macro|View". See http://www.xmlmind.com/xmleditor/_distrib/doc/help/recordMacroMenu.html



I think the suggestion at
https://www.mail-archive.com/[email protected]/msg02082.html
contains useful pointers for both questions (the $dotOffset variable and
the use of <set variable>), but so far I haven't been able to make a
useful macro with them. In order to shortcut precious time: has this
been done before, and are examples available somewhere?


No.

Note that I'm not sure that what you want to do can be implemented as a macro-command and this even if everything needed to implement this macro seems to be available.

Of course, this can be implemented as a Java command. See http://www.xmlmind.com/xmleditor/_distrib/doc/dev/command.html




--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to