Very helpful, thank you. Last descendant text node of currently-selected node therefore is:
<set variable="selected" context="$selected" expression="(.//text())[last()]"/> Bng On 5/1/15, 3:32 AM, "Hussein Shafie" <huss...@xmlmind.com> wrote: >On 04/30/2015 09:37 PM, Boris Goldowsky wrote: >> I¹m trying to make a configuration that allows for convenient building >> of ³Cloze passages², which are essentially fill-in-the-blanks exercises >> like this: >> >> The quick ______ jumped over the ______ Š >> >> Or in XML: <clozepassage><p>The quick <clozeword/> jumped over the >> <clozeword>Š. </p></clozepassage> >> >> I want to have a command button after the <clozepassage> that adds a >> <clozeword/> at the end (but inside the <p>), unless the last node is >> already a <clozeword/>. >> >> I am just running into a little trouble since I need to select the >> /last/ /node that¹s a descendant/ of <clozepassage>. Not last child, >> which would be the <p>, but the text node that¹s ³Š² in this example. >> There might be more structure in the way it could be multiple >> paragraphs, or a list with list items instead of a paragraph, for >> instance. I don¹t see how to do this with selectNode, or what >> alternative methods there might be? >> > >A powerful, XPath 1.0 based, alternative to command "selectNode" is the ><set> descendant element of <macro>: > >--- ><set > variable = QName > context = XPath expr. returning a node set : "/" > expression = XPath expression > plainString = boolean : false >/> >--- > >Some variable names are ``mapped'' to the node selection: "selected", >"selected2", "selectedElement", "selectedNode", "selectedNodes". > >Example: starting from implicitly selected element, select the closest >ancestor having a "linkend" attribute: > >--- ><set variable="selectedElement" context="$implicitElement" > expression="(ancestor-or-self::*[@linkend])[last()]" /> >--- > > > >References: > >* Macro commands, Reference, >http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.htm >l > >* XPath variables >http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html > >* Command selectNode >http://www.xmlmind.com/xmleditor/_distrib/doc/commands/selectNode.html > -- XMLmind XML Editor Support List xmleditor-support@xmlmind.com http://www.xmlmind.com/mailman/listinfo/xmleditor-support