maik.scheibler at sab.sachsen.de wrote:
> Hello,
> 
> i try to create a macro command which is not allowed to execute if a
> specific XHTML element is selected, but it may run if the text node of
> that element is selected.
> How do i achieve this?
> 
> I tried:
> ...
> <sequence>
>     <fail>
>         <command name="selectNode" parameter="self td"/>
>     </fail>
>     ...
> </sequence>
> ...
> 
> This yields only nearly the desired result (but not exactly), because it
> does also prevent the execution when "td->#text" is selected. What i
> want is to prevent execution only if "td" is explicitly selected.
> 
> I was not able to find out how to test for the selection of the text
> node.
> Can anyone help?
> 

When you cannot do it with plain commands such as selectNode, you need 
to use the XPath-based constructs (test, get, set, match). See 
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html

Example:

---
   <binding>
     <keyPressed code="F3" />
     <command name="noTdPlease" />
   </binding>

   <command name="noTdPlease">
     <macro>
       <sequence>
         <test expression="not($selectedElement) or
                           local-name($selectedElement) != 'td'" />
         <command name="alert"
           parameter="Congratulations, you haven't selected a td!" />
       </sequence>
     </macro>
   </command>
---


Reply via email to