XPATH evaluation of ancestor-or-self
Posted: Fri Nov 14, 2025 4:28 pm
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: 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:
Is there a workaround to get this working in standalone and WebAuthor component?
Best regards
Marion
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: 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>
Best regards
Marion