Boris Goldowsky wrote:
> 
> In the DTD I am working with (DAISY DTBook), sections can be nested like 
> this:
> 
> <level1>
>    <h1>header</h1>
>    <p>Introduction</p>
>    ...
>    <level2>
>       <h2>header</h2>
>       <p>Text</p>
>       ...
>    </level2>
>    ...
> </level1>
> 
> Up to <level6>.
> 
> Sometimes one needs to promote or demote a section -- ie, you might want 
> to change the above to be two sibling <level1> elements.
> 
> If I'm not missing something, then this is an incredibly painstaking 
> operation in XXE - you'd have to create the new <level1> element, create 
> the <h1> within it, move the content over piece by piece, 

Why piece by piece? Please use node range selection whenever possible.
See
http://www.xmlmind.com/xmleditor/_distrib/doc/user/being_productive.html#node_range



> then delete 
> the skeleton of the old <level2>.  If the <level2> you were promoting 
> contained <level3> elements, there would be exponentially more steps.
> 

Yes, it is painstaking because unfortunately the DTBook grammar has
chosen the <level1>/<h1>, <level2>/<h2>, <level3>/<h3>, etc, design
instead of choosing the <section> with <title> and nested <section>s design.



> Is there any way to automate this that isn't terribly complicated?  
> Macro, Java command, something else?  If I write an XSLT that does the 
> transformation, can I call that from a menu item (and pass it the 
> selected node)?  Any examples of similar processing that I could look at?
> 

We have written commands in Java[tm] for DocBook that do just this:
*  Command "docb.demote"
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditext/docbook/Demote.html
* Command "docb.promote"
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmleditext/docbook/Promote.html
We can send you the source code of these commands if you are interested.

It is also possible to write an XSLT transformation and use it in a
process command (possibly itself invoked by a macro-command).
* http://www.xmlmind.com/xmleditor/_distrib/doc/commands/process.html
* http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro.html




Reply via email to