Jirka Kosek wrote:
> is there any way to comment out selection which may include several nodes?

* Out of the box, the answer is no.

* If you take the time to write a custom command in Java[tm], you can do 
anything you want.

* If you prefer, you can attempt to write a (rather complex) 
macro-command (Note: writing a *complex* macro-command is *not* 
recommended).

Here's a macro-command which can be used to comment out a *single* element:

---
   <!-- =================================================================
     Wraps an element in a comment.

     * You need to explicitly select an element before
       using this command.
     * The selected element must not contain a comment.
     * This simple version should work fine with documents
       conforming to a DTD, but needs to be improved for use with
       multi-namespace documents conforming to a W3C XML Schema.
   ================================================================== -->

   <binding>
     <keyPressed code="ESCAPE" />
     <charTyped char="&apos;" />
     <command name="wrapInComment" />
   </binding>

   <command name="wrapInComment">
     <macro undoable="true">
       <sequence>
         <pass><command name="delete" /></pass>

         <set variable="elementPrefix"
           expression="concat('&lt;', local-name($selectedElement))" />

         <command name="grabSelectedElement" />
         <set variable="elementData" expression="%_"
              plainString="true" />

        <command name="insertNode" parameter="commentAfter" />
        <set variable="newComment" expression="$selected" />

        <command name="selectNode" parameter="previousSibling" />
        <command name="delete" />

        <set variable="dot" expression="$newComment" />
        <get expression="concat($elementPrefix,
                             substring-after($elementData,
                                         $elementPrefix))" />

         <command name="paste" parameter="into %_" />
       </sequence>
     </macro>
   </command>

   <command name="grabSelectedElement">
     <process showProgress="false">
       <copyDocument selection="true" to="element.xml"
                     indent="true" encoding="UTF-8" />
       <read file="element.xml" encoding="UTF-8" />
     </process>
   </command>
---

You'll find the above macro-command in 
<XXE_install_dir>/docs/config/samples2/customize.xxe.


Reply via email to