Working with ${selection} in Action / XPath

Oxygen general issues.
friedemann_bach
Posts: 48
Joined: Wed Oct 22, 2014 4:11 pm

Working with ${selection} in Action / XPath

Post by friedemann_bach »

Dear Forum,

I am configuring Oxygen Author for transcribing and formatting historical texts. The main issue are the formattings (like bold, italic, etcetera). An example:

Code: Select all

<p>Lorem ipsum dolor sit amet, <hi rend="italic">consectetur <hi rend="bold">adipisici</hi> elit</hi>, sed <hi rend="bold italic">eiusmod</hi> tempor incidunt ut labore et dolore magna aliqua.</p>
As you can see, the attribute @rend describes the appearance of the section surrounded by <hi>. Now I am building actions to influence @rend, which work like on/off-switches, e.g. the "italic" action should add <hi rend="italic"> to the current selection or add the token "italic" to @rend if it already exists, or delete it when it is already present, or delete the whole <hi> when "italic" is the only token in @rend.

This works fine, so far. My actions are:

(1) self::hi[@rend='italic']
=> UnwrapTagsOperation on self::hi[@rend='italic']
(within <hi>, unwrap <hi> if @rend contains only "italic")

(2) self::hi[contains(@rend,'italic')]
=> ChangeAttributeOperation on self::hi[contains(@rend,'italic')] with ${xpath_eval(normalize-space(replace(@rend,"italic","")))}
(within <hi>, remove "italic" from @rend if it contains more tokens)

(3) self::hi[not(contains(@rend,'italic'))]
=> ChangeAttributeOperation on self::hi[not(contains(@rend,'italic'))] with ${xpath_eval(normalize-space(concat(@rend," italic")))}
(within <hi>, add "italic" to @rend if it is not present)

(4) ancestor::text and not(self::hi)
=> ToggleSurroundWithElementOperation with <hi rend="italic" xmlns="http://www.tei-c.org/ns/1.0"/>
(in all other cases, surround the selection with <hi rend="italic">)

Now I would like to modify this in a way that works also for nested elements, as in the example above. So the rule would be: Within <hi>, if text is selected, and if @rend does not contain "italic", surround the selection with <hi rend="italic">. This would be before the third action. I could not figure out, though, how to work with the selection; I tried ${selection} in the XPath condition, but it does not evaluate. I would be grateful for every hint.
radu_pisoi
Posts: 403
Joined: Thu Aug 21, 2003 11:36 am
Location: Craiova
Contact:

Re: Working with ${selection} in Action / XPath

Post by radu_pisoi »

Hi,

I'm assuming you are talking about the Bold/Italic/Underline actions from the TEI document type.

In the latest oXygen version, 17.1, we have improved the functionality of this actions to be aware if the editing context contains nested 'hi' elements.

Let's take a sample:

Code: Select all

<hi rend="italic">t1 {sel_start}t2 <hi rend="bold">t3</hi> t4{sel_end} t5</hi>
In this case, the result of Bold action will be:

Code: Select all

<hi rend="italic">t1 <hi rend="bold">t2 t3 t4</hi> t5</hi>
Do you have the latest oXygen version? If not, could you upgrade your oXygen version to 17.1 or use a trial license?

Please let us know if the latest implementations of the Italic/Bold/Underline actions cover your use-cases.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Post Reply