On Wed, 10 Jun 2009 11:36:54 -0700, Stewart Shelline <[email protected]> wrote:

I need to be able to add processing instructions to documents I create and store in ML. I assumed the following would accomplish that:

    let $xml-version := <?xml version="1.0" encoding="UTF-8"?>
let $stylesheet := <?xml-stylesheet type='text/xsl' href='http://ldschurch.dataformat.com/local/PMDC_TEISchema_Normal.xsl'?>
    let $tei := <teiCorpus ...>...</teiCorpus>
    return xdmp:document-insert( $uri, ($xml-version,$stylesheet,$tei) )

However, this throws the following error:

XDMP-XMLPI: (err:XPST0003) <?xml version="1.0" encoding="UTF-8"?> -- Processing instructions may not have the target 'XML'

Sorry for the newbie question, but what am I missing here?

The first one is not, in fact, a processing instruction.  I know it looks
exactly like one, but technically it is the XML declaration. In XQuery you
are not allowed to construct a processing instruction that has "xml"
as its target precisely to prevent you from trying to construct the
XML declaration in this way.  And that is because the XML declaration
is really a hint for the XML parser and therefore exists outside of the
scope of the XML data model, which is all XQuery knows about.

Even setting that aside, you want to set up your insert a little differently
like so:

xdmp:document-insert( $uri, document { $stylesheet, $tei } )

(Document insert is expecting a single node.)

//Mary
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to