压缩XML后失去缩进

时间:2018-11-16 13:56:16

标签: basex

我正在从数据库中读取文件,并将其压缩并写入本地磁盘,而压缩后会删除XML的格式,但是当我从数据库读取并写入而不压缩时,使用相同的文件就可以了,以下是我压缩内容以及输入和预期输出的代码:

代码:

let $cid := 'b-9781784517544'
let  $docuri :=fn:uri-collection(fn:concat('bloomsbury','/content'))[fn:tokenize(.,'/')[4]=$cid] 
[fn:not(fn:contains(.,'audit') 
or fn:contains(.,'version')                                                                
or fn:contains(.,'properties')                                                                
or fn:contains(.,'header')                                                                
or fn:contains(.,'metadata')
)]
let $filename := fn:tokenize($docuri,'/')[fn:last()] 
let $archive  := archive:create($filename ! element archive:entry { $filename  }, bin:encode-string(fn:serialize((fn:doc($docuri))))   )
return
file:write-binary('C:\dharmendra\test1234.zip', $archive)

当前输出:

<book><p>this is java tutorial</p> <p>this is C# tutorial</p> <p>this is Php tutorial</p> <p>this is ruby tutorial</p> <p>this is hadoop tutorial</p></book>

预期输出:

<book>
    <p>this is java tutorial</p>
    <p>this is C# tutorial</p>
    <p>this is Php tutorial</p>
    <p>this is ruby tutorial</p>
    <p>this is hadoop tutorial</p>
</book>

0 个答案:

没有答案