Hi Florent Georges,

Yes, you are correct . the single & is working fine with repair-full option 
. That's why am confused for < with repair-full is not working.


By
Raja>>>

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Florent Georges
Sent: Wednesday, February 03, 2016 4:40 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] XML entity reference not working in 
xdmp:unquote

Hi,

It is less surprising is you inspect what's in the string.  If you write '<', 
the string contains 1 character, which is '<'.  Another way to obtain the same 
string is to write '&lt;'.  This produces a string containing 1 character, 
which is '<'.

Which means that $data contains a text node, the value of which is ill-formed 
XML.  Almost XML, but for the extra '<' before the closing tag '</data5>'.

To be honest, I am surprised the '&amp;' does not throw an error.  It is 
resolved to a simple '&' in the string.  When you try to parse that, that is an 
XML parsing error.  Probably "repair-full" makes it pass.

If you really want the string to contain valid predefined entities, in order to 
have a string which is well-formed lexical XML, then you need to escape them in 
XQuery:

    xdmp:unquote(
       '<story id="1">
           <data>XML Entity reference Test</data>
           <data1>XML entity 1. &amp;amp; </data1>
           <data2>XML entity 2. &amp;apos; </data2>
           <data3>XML entity 3. &amp;quot; </data3>
           <data4>XML entity 4. &amp;gt; </data4>
           <data5>XML entity 5. &amp;lt; </data5>
        </story>')

Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 3 February 2016 at 09:24, ? wrote:
> Hi Team,
>
>
>
> Today am facing some strange behavior in xdmp:unquote function. I tested the
> below sample code . it’s returning error for entity reference &lt;, but
> remaing 4 working fine. Is this expected bug in ML. or am I missing
> something in the code.
>
>
>
> let $data := text{'<story id="1">
>
>                       <data>XML Entity reference Test</data>
>
>                       <data1>XML entity 1. &amp; </data1>
>
>                       <data2>XML entity 2. &apos; </data2>
>
>                       <data3>XML entity 3. &quot; </data3>
>
>                       <data4>XML entity 4. &gt; </data4>
>
>                       <data5>XML entity 5. &lt; </data5>
>
>              </story>'}
>
>
>
> return
>
> xdmp:unquote(fn:concat("<a xml:space
> =""preserve"">",$data,"</a>"),"",("repair-full"))
>
>
>
> the XML content coming as string , so we are using this unquote function to
> make it as XML content. Kindly help on this issue .
>
>
>
> By
>
> Raja>>>
>
>
>
> This e-mail and any files transmitted with it are for the sole use of the
> intended recipient(s) and may contain confidential and privileged
> information. If you are not the intended recipient(s), please reply to the
> sender and destroy all copies of the original message. Any unauthorized
> review, use, disclosure, dissemination, forwarding, printing or copying of
> this email, and/or any action taken in reliance on the contents of this
> e-mail is strictly prohibited and may be unlawful. Where permitted by
> applicable law, this e-mail and other e-mail communications sent to and from
> Cognizant e-mail addresses may be monitored.
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of this e-mail is strictly 
prohibited and may be unlawful. Where permitted by applicable law, this e-mail 
and other e-mail communications sent to and from Cognizant e-mail addresses may 
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to