Bill Fenner wrote:
> I'm having some trouble getting the desired behavior from insertNode.
> 
> My document type has a PI that can be used to include files, a
> poor-man's modular document creation method.  I've been trying to
> figure out how to insert a PI into an empty <references> section -
> 
> insertNode piInto[implicitNode]
> insertNode piInto[implicitElement]
> 
> don't work.

Like all ``into-s'', it does not make sense to specify [implicitNode] or
[implicitElement].

That is: "insertNode piAfter[implicitNode] php" is OK, but not
"insertNode piInto[implicitNode] php".

Yes, the doc
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/insertNode.html
could be made clearer.



> insertNode piInto
> 
> does, but has a different problem.  If the caret is between the two
> quotes of
> 
> <?rfc include='reference.'?>
> 
> and I execute
> 
> insertNode piInto rfc
> 
> I get
> 
> <?rfc include='reference.?>
> <?rfc ?>
> <?rfc '?>
> 
> where I was hoping to get an execution failure so that a subsequent
> "insertNode piAfter" could have a change.
> 
> Is this expected behavior?  If it's a bug, can you think of a workaround?

There is no bug here. This is the expected behavior. Inserting a PI
inside a PI is possible: it just splits the PI in two parts and then
inserts the new PI in the middle. Same behavior with comments.

It should be possible to detect that the caret is inside a PI or that a
PI is being explicitly selected by using a (XPath-based) match child
element in a macro command. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html

The corresponding easy-to-use Java API is:
http://www.xmlmind.com/xmleditor/_distrib/doc/api/com/xmlmind/xmledit/xpath/XPathUtil.html#matches(com.xmlmind.xmledit.doc.XNode,%20java.lang.String,%20java.util.HashMap)

Reply via email to