If you’re checking your XQuery’s output in the Query Console, it may 
actually be doing what you want.  But the result of your XQuery is re-formatted 
for display in the browser.  As Florent said, CDATA is not real XML, it’s just 
an escaping mechanism.  So your CDATA output may have been parsed and 
re-serialized to the equivalent simple XML for display.

   The best solution is to educate the broken app that you’re sending the data 
to to be standards compliant and accept valid XML.  But that may not be under 
your control.

> On Oct 20, 2015, at 3:28 PM, Schouten, Edgar J. (RB-NL) 
> <[email protected]> wrote:
> 
> Hi Florent 
>  
> Thanks for your reply.
>  
> I can temporarily bypass the problem by manually changing replacing 'fake' 
> <CDATA>-fields by <![CDATA[-fields as a post-proces.
> The import in the application works fine after the replacement.
>  
> I've put a output.xqy file in my Marklogic-Apps folder that I run through the 
> browser (http://localhost:8000/export.xqy <http://localhost:8000/export.xqy> )
>  
> The file basicly creates a node and saves it (simplified). I added the 
> cdata-section-element also to the options of xdmp:save.
>  
> xquery version "1.0-ml";
> declare option xdmp:output "cdata-section-elements=rules";
>  
> let $myVart := 1
> return
>      xdmp:save
>      (
>           "C:\LocalDisk\test.xml",
>           <TeragramDirectoryStructureV3>
>                <myElement>{$myVar}</myElement>
>           </TeragramDirectoryStructureV3>,
>           <options xmlns="xdmp:save">
>                 <output-encoding>utf-8</output-encoding>
>                <cdata-section-elements>myElement</cdata-section-elements>
>           </options>
>      )
>  
>  
> -----Oorspronkelijk bericht-----
> Van: [email protected] 
> [mailto:[email protected]] Namens Florent Georges
> Verzonden: dinsdag 20 oktober 2015 16:10
> Aan: MarkLogic Developer Discussion <[email protected]>
> Onderwerp: Re: [MarkLogic Dev General] cdata-section-elements option doesn't 
> produce CDATA-values
>  
> On 20 October 2015 at 15:45, Schouten, Edgar J. (RB-NL) wrote:
>  
>   Hi,
>  
> > This application requires <![CDATA[-fields
>  
>   Which means it is not expecting XML.  CDATA is syntactic sugar.
> Whether it is used or not, equivalent XML documents should be treated the 
> same (regardless of CDATA sections).  Not everything has to be XML, so it 
> might be OK, but often "issues" with CDATA are an application configured the 
> wrong way and rejecting well-formed XML when it should not.
>  
> > declare option xdmp:output "cdata-section-elements=myElement";
>  
>   This can be applied only if the serializer gets into play.  How are you 
> evaluating the query, and how are you saving (or displaying) its result?
>  
>   Regards,
>  
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at: 
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> [email protected] <mailto:[email protected]>
> Manage your subscription at: 
> http://developer.marklogic.com/mailman/listinfo/general 
> <http://developer.marklogic.com/mailman/listinfo/general>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to