What you want to do is quite hard to do using a macro and quite easy to 
to by modifying makeParagraphs (a command written in Java). I mean, 
*complex* macros can almost always be implemented quickly and easily in 
Java.

Now, this being said, I rewrote your insertAfterAsListitem as follows:

---
<?xml version='1.0' encoding='ISO-8859-1'?>
<configuration
xmlns="http://www.xmlmind.com/xmleditor/schema/configuration";
xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:su="java:com.xmlmind.xmledit.util.StringUtil">

   <binding>
     <keyPressed code="F2" />
     <command name="insertAfterAsListItems" />
   </binding>

   <command name="insertAfterAsListItems">
     <macro trace="true">
       <sequence>
        <command name="makeParagraphs" parameter="listitem" />
         <set variable="paragraphs" expression="%_" plainString="true" />
         <set variable="paragraphs"
              expression='su:replaceAll($paragraphs,
                "&lt;listitem xmlns=&apos;&apos;&gt;",
                "&lt;listitem xmlns=&apos;&apos;&gt;&lt;para&gt;")' />
         <get expression='su:replaceAll($paragraphs,
                "&lt;/listitem&gt;",
                "&lt;/para&gt;&lt;/listitem&gt;")' />
        <command name="paste" parameter="after %_" />
       </sequence>
     </macro>
   </command>
</configuration>
---

This is of course ridiculously complex (because you need to use a Java 
static method: com.xmlmind.xmledit.util.StringUtil.replaceAll, found in 
the XXE runtime) but it works.

To test the above insertAfterAsListitem, *explicitly* select the 
listitem after which you want to paste more items and press F2.

You'll find the customized.xxe file I used to test my 
insertAfterAsListitem, attached to this email. And you'll probably want 
to turn trace off (remove trace="true").

versorger at gmx.li wrote:
> I could need some help with a macro. I want to paste text from the clipboard
> as docbook listitems. makeParagraphs just seemed fine for this purpose and I
> made command to add an itemizedlist, paste the listitems from the clipboard
> and remove the first listitem (it is empty). 
> 
> Now this all works, except for one thing: the listitems lack a para element
> and thus I get an invalid document. I tried to add an elementTemplate to
> override listitem with listitem/para, but without success. 
> 
> Here the two commands:
> 
> <command name="pasteAsList">
>   <macro>
>     <sequence>
>       <command name="docb.addAfter" parameter="itemizedlist" />
>       <command name="selectNode" parameter="childOrNode" />                
>       <command name="insertAfterAsListitem"/>
>       <command name="selectNode" parameter="firstSibling"/>
>       <command name="delete" />
>     </sequence>
>   </macro>
> </command>
> 
> <command name="insertAfterAsListitem">
>   <macro>
>     <sequence>
>       <command name="makeParagraphs" parameter="listitem" />
>       <command name="paste" parameter="after[implicitElement] %_" />
>     </sequence>
>   </macro>
> </command>
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: customize.xxe
Type: text/xml
Size: 1086 bytes
Desc: not available
Url : 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20041001/22080c64/attachment.xml
 

Reply via email to