[xquery-talk] XML prologue

Michael Kay mhk at mhk.me.uk
Wed Jul 27 00:51:49 PDT 2005


A couple of comments:

I don't know the specification of tig:insert-document, but I would have
expected its second argument to be a document rather than a query:

tig:insert-document("mydocument", "<?xml version="1.0"?><billofsale>
<amount>500</amount></billofsale>" )

This would mean that the above (once you escape the quotes around "1.0")
would be valid syntax.

There are many other respects in which a valid XML document might not be a
valid query: for example, if it contains a DOCTYPE declaration, or external
entity references.

Also, the update facility that the WG is starting to work on looks nothing
like this at all.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of Frank Cohen
> Sent: 26 July 2005 23:29
> To: talk at xquery.com
> Subject: Re: [xquery-talk] XML prologue
> 
> Thanks for the help understanding the issue. I wrote this up for  
> future newbies at:
> http://www.xquerynow.com/howto/thebasics/xmldeclaration.html
> 
> -Frank
> 
> 
> On Jul 25, 2005, at 4:10 PM, Jason Hunter wrote:
> 
> > I don't believe there's an XQuery standard function to do 
> that.  In  
> > MarkLogic you can use xdmp:unquote().
> >
> > let $b := '<?xml version="1.0"?><name>frank</name>'
> > return xdmp:unquote($b)
> >
> > This returns the <name> element as an element.  You could do  
> > xdmp:unquote($b)/text() for example.
> >
> > -jh-
> >
> > Frank Cohen wrote:
> >
> >
> >> 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
> >> -Frank
> >> On Jul 25, 2005, at 3:14 PM, Michael Dyck wrote:
> >>
> >>> Frank Cohen wrote:
> >>>
> >>>
> >>>>
> >>>> let $b :=<?xml version="1.0"?><frank/>
> >>>>
> >>>> $b fails with a lexxing error.
> >>>>
> >>>> I read the XQuery 4/2005 spec and don't see that this is not  
> >>>> allowed
> >>>> but the 3 different XQuery processors I ran this on all have a
> >>>> problem with it.
> >>>>
> >>>>
> >>>
> >>> There are a couple of things that they might be complaining about.
> >>>
> >>> (1)
> >>> To the XQuery grammar, <?xml version="1.0"?> looks like a
> >>> DirPIConstructor (direct processing-instruction constructor);  
> >>> however,
> >>> 'xml' is not allowed as a PITarget.
> >>>
> >>> (2)
> >>> If the parser is being lax about PITargets, or is delaying that   
> >>> check to
> >>> a later phase, then it's probably complaining that you have a
> >>> (top-level) DirPIConstructor followed by a DirElemConstructor,   
> >>> which is
> >>> a syntax error. (ExprSingle derives PrimaryExpr derives   
> >>> Constructor, not
> >>> Constructor+.) It's syntactically on par with
> >>>     let $b := 1 2
> >>> or
> >>>     let $b := "hello" "world"
> >>>
> >>> -Michael Dyck
> >>> _______________________________________________
> >>> talk at xquery.com
> >>> http://xquery.com/mailman/listinfo/talk
> >>>
> >>>
> >>>
> >> _______________________________________________
> >> talk at xquery.com
> >> http://xquery.com/mailman/listinfo/talk
> >>
> > _______________________________________________
> > talk at xquery.com
> > http://xquery.com/mailman/listinfo/talk
> >
> >
> 
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 




More information about the talk mailing list