We have an XML structure that we've added to DocBook (v5), which looks 
like this in the RNC format:
         element bundle {
           langData+,
           gloss
         }
So it has a variable number of daughters--at least two, sometimes three, 
and at least theoretically more.

This structure itself is embedded inside another (invariant) structure; 
the parent will always have at least one 'bundle', and is created using 
an xxe <elementTemplate>.

We currently have two such templates: one contains a bundle with two 
daughters--one langData and one gloss; the other contains a bundle with 
three daughters--two langData elements, and of course one gloss element. 
The <langData> and <gloss> elements each contain mixed text elements 
(generally plain text, or text plus <emphasis> or <superscript>).

We want to assign an XXE macro (and a keystroke) to create additional 
'bundle' structures inside this parent, but with a constraint: the 
additional bundles must have the same number of daughters as the 
existing bundle.  That is, if the existing <bundle> has one <langData> 
element, so must the new bundle; or if the existing one has two such 
elements, so must the new one.  Furthermore, the new <langData> and 
<gloss> elements should be empty, with no text inside.

I haven't found a way to do this.  I've tried various things, e.g.
         <command name="selectNode"
                  parameter="ancestorOrSelf[implicitElement]
                  {http://casl.umd.edu/Interlinearization}bundle"/>
         <command name="copy" parameter="[implicitElement]"/>
         <command name="paste" parameter="after[implicitElement]"/>
But this copies the text *with* the <langData> and <gloss> elements.  I 
haven't found a way to automatically delete the text inside these.  I 
thought maybe
         <command name="replaceText" parameter="[ra] '.' ''"/>
would work (thinking it would restrict the replacement to the selected 
new node), but this appears to hang (possibly it's trying to replace all 
the text in the entire document, one character at a time?).

I've also tried
         <command name="insertNode" parameter="sameElementAfter"/>
but this appears to insert the minimal element allowed by the schema, in 
this case a <bundle> with a single <langData> element (and a single 
<gloss>), regardless of whether the existing <bundle> has one or two 
<langData> elements.

I've tried a few variants of these, with no luck.

Is there a way to automatically construct a copy of an element, but 
without any text it might contain? Maybe a copy to a certain depth?

It is the case that all the <bundle>s in any given document will have 
the same number of <langData> objects.  So I suppose I could create some 
kind of empty <bundle> in each document, maybe inside a <remark> (so it 
wouldn't appear) with an xml:id, and make the macro copy that using 
selectById, then searching inside this <remark> for the daughter node to 
be copied; then it would need to find its way back to where the 
insertion is supposed to take place...
-- 
        Mike Maxwell
        maxw...@umiacs.umd.edu
         "A library is the best possible imitation, by human beings,
         of a divine mind, where the whole universe is viewed and
         understood at the same time... we have invented libraries
         because we know that we do not have divine powers, but we
         try to do our best to imitate them." --Umberto Eco
 
--
XMLmind XML Editor Support List
xmleditor-support@xmlmind.com
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to