Thanks for the reply. Since the only empty node that it makes sense
to insert into is "references", I've done the following:
<choice>
<!-- If we've got a references section selected, then either:
- it's empty, so we can insert piInto
- it's got content, so we can select the last element
and insert after. -->
<sequence>
<test context="$implicitNode" expression="self::references"/>
<choice>
<command name="insertNode" parameter="piInto rfc"/>
<sequence>
<command name="selectNode" parameter="lastChild"/>
<command name="insertNode"
parameter="piAfter[implicitNode] rfc"/>
</sequence>
</choice>
</sequence>
<command name="insertNode" parameter="piAfter[implicitNode] rfc"/>
</choice>
This either uses "piInto" an empty references element, or goes to the
last child and inserts after; otherwise, in the general case, it just
does after. This seems to do what I want in the test cases I've
tried.
Bill