For element nodes, the the 2nd argument expression
should evaluate to something like
"<element-name att-name='attvalue' ...>". The
characters are optional. If no attributes are used, the
expression may simply consist the element name. Note,
that in the first case, the quotes are required since
the expression contains spaces.
Attribute nodes use the following syntax: "att-name='attvalue' [...]".
For the other types of nodes (text, cdata, comments) the expression should contain the node's literal content. Again, it is necessary to quote all whitespace and special characters as in any expression argument.
Optionally, for element and attribute nodes,
a namespace may be specified with
:n. If used,
the expression should evaluate to the desired namespace
URI and the name of the element or attribute being inserted
must have a prefix.
The command returns a node-list consisting of nodes it created.
Note, that instead of
xinsert, you can alternatively use
one of xsh:new-attribute,
together with the command xcopy.
Example 58. Give each chapter a provisional title element.
my $new_titles := xinsert element "<title font-size=large underline=yes>" \ into /book/chapterxsh>
xinsert text "Change me!" into $new_titles;
Example 59. Same as above, using xcopy and xsh:new-... instead of xinsert
my $new_titles := xcopy xsh:new-element("title","font-size","large","underline","yes") \ into /book/chapterxsh>
xcopy xsh:new-text("Change me!") into $new_titles;