[xquery-talk] XML prologue

Michael Kay mhk at mhk.me.uk
Tue Jul 26 01:08:35 PDT 2005

> Both make sense to me. Thank you Michael. I'm wondering if 
> there is a  
> built-in function that would strip the xml prologue from a String so  
> I could use something like this:
> let $b := '<?xml version="1.0"?><name>frank</name>'
> return doc-strip-prologue($b)/name

You've got a string here: stripping characters off the start of the string
isn't going to give you a tree that you can use path expressions on. To get
a tree from a string containing lexical XML you need an XML parser.

Saxon has an extension function saxon:parse() which allows you to do this
operation. It's more usual, however, for the lexical XML to be in an
external resource that's accessed using the doc() function.

Michael Kay

More information about the talk mailing list