[xquery-talk] XML prologue
jhunter at xquery.com
Mon Jul 25 17:10:33 PDT 2005
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>'
This returns the <name> element as an element. You could do
xdmp:unquote($b)/text() for example.
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
> 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.
>> To the XQuery grammar, <?xml version="1.0"?> looks like a
>> DirPIConstructor (direct processing-instruction constructor); however,
>> 'xml' is not allowed as a PITarget.
>> 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
>> let $b := "hello" "world"
>> -Michael Dyck
>> talk at xquery.com
> talk at xquery.com
More information about the talk