[xquery-talk] XML prologue

Frank Cohen fcohen at rainingdata.com
Tue Jul 26 16:28:56 PDT 2005


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
>
>




More information about the talk mailing list