Denis wrote:
> I'm just diving into the xxe commands - a newbie question: I expected
> the following
> configuration code in customize.exe to open emacs on Linux, notepad on
> Windows:
> 
> <command name="editXMLSource">
>     <macro>
>       <sequence>
>         <command name="XXE.save" parameter="[ifNeeded]" />
>         <choice>
>           <command name="run" parameter='c:\windows\system32\notepad.exe
> "%D"' />
>           <command name="run" parameter='emacs "%D"' />
>         </choice>
>         <command name="XXE.open" parameter="[reopenIfNewer]" />
> 
>       </sequence>
>     </macro>
>   </command>
> 
>   <binding>
>     <keyPressed code="ESCAPE" />
>     <charTyped char="e" />
>     <command name="editXMLSource" />
>   </binding>
> 
> According to the doc, "the choice element will execute the first
> alternative which
> can be executed". Instead, the macro fails if the first choice fails: So
> as written,
> the macro works only on Windows. On Linux it fails with this error:
> Execution failed
> with exit status 127. /bin/sh: c:windowssystem32notepade.exe: command
> not found.
> 
> What am I misunderstanding?

What you did is pretty intuitive, however there is a misunderstanding:

``the choice element will execute the first alternative which can be
executed''

should read:

``the choice element will execute the first alternative which, given the
editing context, makes it possible attempting its execution''

And, of course, there is nothing on Linux which could prevent XXE from
attempting to execute
/bin/sh -c 'c:\windows\system32\notepad.exe "foo.xml"'

In the absence of a higher-level facility in XXE, you need to rewrite
the macro like this:

---
  <command name="editXMLSource">
    <macro>
      <sequence>
        <command name="XXE.save" parameter="[ifNeeded]" />
        <choice>
          <sequence>
            <test
              expression="system-property('path.separator') = ';'" />
            <command name="run"
                     parameter='c:\windows\system32\notepad.exe "%D"' />
          </sequence>

          <command name="run" parameter='emacs "%D"' />
        </choice>
        <command name="XXE.open" parameter="[reopenIfNewer]" />
      </sequence>
    </macro>
  </command>
---

Note that system-property() is only available in XXE V3.0 Patch 1. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathfunc.html

---
PS: Simpler, install GNU Emacs on Windows
(http://www.gnu.org/software/emacs/windows/ntemacs.html).
Works great ;-)


Reply via email to