I'm trying to work out how to insert a processing-instruction (stylesheet) into my documents. I've tried three methods without result.

1) Using XQuery Update Extensions

If I try to insert the pi preceding the document node, I get a null pointer exception.
I can insert into the document node, but I want the pi to precede the document node.

2) Using XUpdate in an XQuery.

I can't construct the XUpdate, let alone apply it.

I keep getting unexpected token ":", the one between xupdate and processing-instruction. This is when using an exact copy of the example from XUpdate Use Cases.

let $c := <xupdate:modifications …>
                <xupdate:insert-before select="/addresses">
                    <xupdate:processing-instruction type="cocoon-process">type="xsp"</xupdate:processing-instruction>
return $c

It appears that I can put just about anything instead of processing-instruction and the above query works. Even "processing-instructio" works.

3) Using XUpdate via Java Code (SOAP Interface)

Again, I get a null pointer exception.

<xupdate:modifications version="1.0" xmlns:xupdate="http://www.xmldb.org/xupdate">
  <xupdate:insert-before select="/document-node()">
    <xupdate:processing-instruction name="xml-stylesheet">type="text/xml" href="http://hiexmldb:8080/schema/HostInfo.xsl"</xupdate:processing-instruction>


The only thing that works is to get the resource from the data-base, convert to to DOM, add the processing-instruction, serialize and write back to database.

I'd prefer to use update/xupdate.

Russell Thamm

IMPORTANT: This email remains the property of the Australian Defence Organisation and is subject to the jurisdiction of section 70 of the CRIMES ACT 1914. If you have received this email in error, you are requested to contact the sender and delete the email.