Hussein, Thank you very much! This was extremely helpful. While I am at it, thank you for the detailed documentation such as the XMLMind XML Editor - Commands document and the Configuration and Deployment document. They are invaluable.
I spent some time last night working on my own menu based on the examples you provided in the Commands documentation. I've pasted it below. It works relatively well (there is are a few behaviors that I can't seem to prevent). I would be very interested in yours or anyone else's opinion. <!-- My menu --> <command name="contextualMenu"> <macro> <choice> <sequence> <!-- If we have selected text, we need contextualMenu1, which calls macros that wrap the text in a phrase element, then set the revisionFlag attribute. If we are removing markup, this menu calls a macro that removes the phrase element. --> <test expression="$selectedChars != ''" /> <command name="contextualMenu1" /> </sequence> <sequence> <!-- If we have not selected text, we need contextualMenu2, which calls macros that set the revisionFlag attribute. If we are removing markup, this menu calls a macro that tries to convert the selection to a text node. This might work for cases other than phrases, but so far XMLMind won't let you convert something to #text if it will make the document invalid. --> <test expression="$selectedChars = ''" /> <command name="contextualMenu2" /> </sequence> <command name="editMenu" /> </choice> </macro> </command> <command name="contextualMenu1"> <menu> <item label="C1: Mark as Added" command="phraseWithAddedRevision" /> <item label="C1: Mark as Changed" command="phraseWithChangedRevision" /> <item label="C1: Mark as Deleted" command="phraseWithDeletedRevision" /> <item label="C1: Remove Markup" command="removeMarkup" /> <!-- <item label="C1: Remove Markup" command="removeAttribute" parameter="revisionflag" /> --> <editMenu /> </menu> </command> <command name="contextualMenu2"> <menu> <item label="C2: Mark as Added" command="addAttribute" parameter="revisionflag added" /> <item label="C2: Mark as Changed" command="addAttribute" parameter="revisionflag changed" /> <item label="C2: Mark as Deleted" command="addAttribute" parameter="revisionflag deleted" /> <item label="C2: Remove Markup" command="removeMarkup" /> <editMenu /> </menu> </command> <binding> <mousePressed button="3"/> <command name="contextualMenu" /> </binding> <command name = "phraseWithAddedRevision"> <macro undoable="true"> <sequence> <command name="wrap" parameter="phrase" /> <command name="selectNode" parameter="self" /> <command name="addAttribute" parameter="revisionflag added" /> </sequence> </macro> </command> <command name = "phraseWithChangedRevision"> <macro undoable="true"> <sequence> <command name="wrap" parameter="phrase" /> <command name="selectNode" parameter="self" /> <command name="addAttribute" parameter="revisionflag changed" /> </sequence> </macro> </command> <command name = "phraseWithDeletedRevision"> <macro undoable="true"> <sequence> <command name="wrap" parameter="phrase" /> <command name="selectNode" parameter="self" /> <command name="addAttribute" parameter="revisionflag deleted" /> </sequence> </macro> </command> <command name = "removeMarkup"> <macro undoable="true"> <sequence> <command name="selectNode" parameter="selfOrElement" /> <command name="removeAttribute" parameter="revisionflag" /> <command name="convert" parameter="#text" /> </sequence> </macro> </command> Right now, the main thing I wish I could change is that the "Remove Markup" menu is selectable even if you select something that has not had its revisionFlag attribute set. But so far, so good. Again, many thanks! Dave Shevitz Hussein Shafie wrote: > David 'Dox' Shevitz wrote: > >> I understand that Docbook includes a revisionflag attribute that >> allows you to let others know that content has been added or changed. >> I was hoping to put together a custom popup menu (or an addition to >> the default popup menu) and a custom toolbar that allows you to >> quickly set this flag to a specific value. For example a user >> right-clicks a para element and has the following options available: >> >> Track Changes: Added (sets revisionflag to Added) >> Track Changes: Changed (sets revisionflag to Changed) >> Track Changes: Deleted (sets revisionflag to Deleted) >> >> It would be particularly useful if the menu had some intelligence >> behind that detected if only text was selected and, if so, wrap the >> text in a phrase element so that a flag could be added. >> >> I've been reading through the Configuration and Deployment guide, but >> I think I'm tackling a task that is more than I can handle, because I >> can't seem to get things to work. Does anyone have any suggestions? > > > Normally DocBook has a context-sensitive Edit popup menu. This popup > menu is special if you click on an svg:svg element. > > I've sacrificied this feature for the sake of making what follows > simpler to understand. > > --- > <command name="mydocb.setRevision"> > <macro undoable="true"> > <sequence> > <choice> > <sequence> > <test expression="string-length($selectedChars) > 0" /> > <get expression="$selectedChars" /> > <!-- Does not select what has been pasted > but the caret is inside what has been pasted. --> > <command name="paste" > parameter="to > <?xml version='1.0'?><phrase>%_</phrase>"/> > </sequence> > > <test expression="$implicitElement" /> > </choice> > > <sequence> > <set variable="selectedElement" expression="$implicitElement" /> > <command name="putAttribute" parameter="revisionflag %0" /> > </sequence> > </sequence> > </macro> > </command> > > <command name="mydocb.editMenu"> > <menu> > <item label="Track Changes: Added (sets revisionflag to added)" > command="mydocb.setRevision" parameter="added" /> > <item label="Track Changes: Changed (sets revisionflag to changed)" > command="mydocb.setRevision" parameter="changed" /> > <item label="Track Changes: Deleted (sets revisionflag to deleted)" > command="mydocb.setRevision" parameter="deleted" /> > > <editMenu /> > </menu> > </command> > > <binding> > <mousePressed button="3"/> > <command name="mydocb.editMenu" /> > </binding> > --- > > To test this, simply copy attached file to > <XXE_user_preferences_dir>/config/ (<XXE_user_preferences_dir> is > C:\Document and Settings\<user>\xxe2\ on Windows and ~/.xxe2/ on Unix). > >------------------------------------------------------------------------ > ><?xml version='1.0' encoding='ISO-8859-1'?> ><configuration name="DocBook" > 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"> > > <include location="xxe-config:docbook/docbook.xxe"/> > > <command name="mydocb.setRevision"> > <macro undoable="true"> > <sequence> > <choice> > <sequence> > <test expression="string-length($selectedChars) > 0" /> > <get expression="$selectedChars" /> > <!-- Does not select what has been pasted but the caret is inside > what has been pasted. --> > <command name="paste" > parameter="to > <?xml version='1.0'?><phrase>%_</phrase>" /> > </sequence> > > <test expression="$implicitElement" /> > </choice> > > <sequence> > <set variable="selectedElement" expression="$implicitElement" /> > <command name="putAttribute" parameter="revisionflag %0" /> > </sequence> > </sequence> > </macro> > </command> > > <command name="mydocb.editMenu"> > <menu> > <item label="Track Changes: Added (sets revisionflag to added)" > command="mydocb.setRevision" parameter="added" /> > <item label="Track Changes: Changed (sets revisionflag to changed)" > command="mydocb.setRevision" parameter="changed" /> > <item label="Track Changes: Deleted (sets revisionflag to deleted)" > command="mydocb.setRevision" parameter="deleted" /> > > <editMenu /> > </menu> > </command> > > <binding> > <mousePressed button="3"/> > <command name="mydocb.editMenu" /> > </binding> > ></configuration> > > >------------------------------------------------------------------------ > > >-- >XMLmind XML Editor Support List >xmleditor-support at xmlmind.com >http://www.xmlmind.com/mailman/listinfo/xmleditor-support >