XPATH evaluation of ancestor-or-self

Having trouble installing Oxygen? Got a bug to report? Post it all here.
mknebel
Posts: 7
Joined: Tue Mar 03, 2015 10:41 pm
Location: Germany
Contact:

XPATH evaluation of ancestor-or-self

Post by mknebel »

We have written an external author action that is supposed to change a value in the @outputclass attribute of a DITA element. The action uses a context rule that should evaluate to the corresponding element, in this case, <image>.

The XPATH works fine if the caret is placed inside of the image element. However, it does not if the element is selected using the breadcrumbs or simply by clicking on it. This is counter-intuitive and seems wrong.

The problem is not the action but the evaluation of the XPATH itself, as can be demonstrated by the following picture:
oxy_problem_xpath.jpg
Is our understanding of the XPATH expression wrong or should it return the <image> element also when it is selected?

For reference, this is one operation within the action that we are designing:

Code: Select all

<a:operation id="ChangeAttributeOperation">
      <a:xpathCondition>ancestor-or-self::image[1][not(@outputclass)]</a:xpathCondition>
      <a:arguments>
        <a:argument name="elementLocation">ancestor-or-self::image[1]</a:argument>
        <a:argument name="name">outputclass</a:argument>
        <a:argument name="namespace"></a:argument>
        <a:argument name="value">${ask('Select image size', editable_combobox, ('small':'small';'medium':'medium';'large':'large'), 'small')}</a:argument>
      </a:arguments>
    </a:operation>
    
Is there a workaround to get this working in standalone and WebAuthor component?

Best regards
Marion
You do not have the required permissions to view the files attached to this post.
Marion Knebel
parson AG
www.parson-europe.com
Radu
Posts: 9595
Joined: Fri Jul 09, 2004 5:18 pm

Re: XPATH evaluation of ancestor-or-self

Post by Radu »

Hi Marion,
The xpath is run having as context the element which contains the caret position.
If the image is selected, the caret is outside of the image.
Maybe you could use a combination of your xpath with this special xpath function we made:
https://www.oxygenxml.com/doc/versions/ ... ement.html
It should work for Oxygen desktop, for WebAuthor from what I remember we never disable our Author actions on the toolbar so we do not use the activation xpath for anything.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
mknebel
Posts: 7
Joined: Tue Mar 03, 2015 10:41 pm
Location: Germany
Contact:

Re: XPATH evaluation of ancestor-or-self

Post by mknebel »

Hi Radu,
Thank you for your input. The special XPATH function solved the problem. We now have operations with ancestor-or-self and with oxy:current-selected-element() in the action. Works like a charm also in WebAuthor.

Best regards
Marion
Marion Knebel
parson AG
www.parson-europe.com
Radu
Posts: 9595
Joined: Fri Jul 09, 2004 5:18 pm

Re: XPATH evaluation of ancestor-or-self

Post by Radu »

Hi Marion,

Great, I'm glad!

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply