HI Joe!

I don't speak XQuery well enough to do this off the top of my head
(plenty of others on this list can), but it is easy to do in XSLT,[1]
so it is probably easy in XQuery, too.

But it is worth quickly pointing out that (what I think is) your
instinct is right: as I read the spec[2], an 'xml-model' processing
instruction is only used when it is a child of the document root that
occurs before the outermost element. So those that appear in every
TEI element may be useful to humans, but should be ignored by XML

 [1] <xsl:processing-instruction name="xml-model">href="" type="application/xml" schematypens=""</xsl:processing-instruction>

> I've created an xquery file (see below) which generates a teiCorpus
> document from a collection of TEI files. I've also created a TEI
> customization. Is there a way to have xquery or eXist insert an <?xml-model
> ?> statement at the head of the corpus document, with the URL pointing to
> my TEI customization RNG file? I've noticed that inside the corpus file,
> these xml-model statements appear before every TEI element.