@@ -280,6 +280,58 @@ describe('Document Metadata values test', function() {
280280 done ( ) ;
281281 } , done ) ;
282282 } ) ;
283+
284+ it ( 'TEST 17 - write and read xml formatted properties in json' , function ( done ) {
285+ var docuri = '/test/query/matchList/propertyInxmlOne.json' ;
286+ this . timeout ( 10000 ) ;
287+ db . documents . write ( {
288+ uri : docuri ,
289+ contentType : 'application/json' ,
290+ quality : 13 ,
291+ properties : { '$ml.xml' : '<prop:properties xmlns:prop="http://marklogic.com/xdmp/property"><myProps>Property 1</myProps></prop:properties>' } ,
292+ content : {
293+ title : 'The memex' ,
294+ popularity : 5 ,
295+ id : '0026' ,
296+ date : '2009-05-05' ,
297+ price : {
298+ amt : 123.45
299+ } ,
300+ p : 'The Memex, unfortunately, had no automated search feature'
301+ }
302+ } ) . result ( function ( response ) {
303+ dbReader . documents . read ( { uris : docuri , categories : [ 'metadata' ] } ) .
304+ result ( function ( documents ) {
305+ var prop = JSON . stringify ( documents [ 0 ] . properties ) ;
306+ //console.log(prop, null, 4);
307+ prop . should . containEql ( '<myProps>Property 1</myProps>' ) ;
308+ done ( ) ;
309+ } , done ) ;
310+ } , done ) ;
311+ } ) ;
312+
313+ it ( 'TEST 18 - appply xml formatted properties patch on metadata properties' , function ( done ) {
314+ this . timeout ( 10000 ) ;
315+ var docuri = '/test/query/matchList/propertyInxmlOne.json' ;
316+ var p = marklogic . patchBuilder ;
317+ db . documents . patch ( { uri : docuri ,
318+ categories : [ 'metadata' ] ,
319+ operations : [
320+ p . collections . add ( 'metadataValuesColl/ADDED' ) ,
321+ p . properties . add ( '$ml.xml' , '<prop:properties xmlns:prop="http://marklogic.com/xdmp/property"><myProps1>Property 2</myProps1></prop:properties>' ) ,
322+ p . quality . set ( 2 )
323+ ]
324+ } ) . result ( function ( response ) {
325+ dbReader . documents . read ( { uris : docuri , categories : [ 'metadata' ] } ) .
326+ result ( function ( documents ) {
327+ var prop = JSON . stringify ( documents [ 0 ] . properties ) ;
328+ //console.log(prop, null, 4);
329+ // Note we expect two properties, but in special case of $ml.xml, the patch just replaces an existing $ml.xml
330+ prop . should . containEql ( '<myProps>Property 2</myProps>' ) ;
331+ done ( ) ;
332+ } , done ) ;
333+ } , done ) ;
334+ } ) ;
283335
284336 it ( 'should delete all documents' , function ( done ) {
285337 dbAdmin . documents . removeAll ( {
0 commit comments