[DELIVER]<output:indent value='no'/> fn:serialize
Saturday, 30 May 2015 · 2 messages
AL
Adam Law30 May 2015 09:29 #
I may be doing something wrong but <output:indent value='no'/> does not appear to work with
fn:serialize
Adamlet $ve_collectlocations :=
<collections><collection>{$page:collection_main_private}</collection></col
lections>
let $parameters := <output:serialization-parameters>
<output:method value='xml'/>
<output:indent value='no'/>
<output:omit-xml-declaration value='yes'/>
<output:encoding value='utf-8'/>
</output:serialization-parameters>
let $vs_result:= <Items>{for $collectlocation in
$ve_collectlocations//collection/text()
for $collect in collection($collectlocation)/*
for $deadline in $collect//Deadline/Open
let $irn := ($collect//FIN)[1]
let $xs_string:=
string(fn:serialize($collect,$parameters))
let $md5 :=
<md5>{xs:hexBinary(hash:md5($xs_string))}</md5>
let $vs_result := <Hit>{md5}</Hit> return $vs_result
}</Items>
return $vs_result
};
CG
Christian Grün30 May 2015 11:32 #
Hi Adam,
If your input documents contained whitespaces, and if these
whitespaces are preserved in the database (e.g. by setting to chop flag to false), they won't be removed in the serialization either. See e.g. the following example:
serialize(<a><b/>{ ' ' }</a>, map { 'indent': 'no' })You can enforce the removal of whitespace nodes by using the transform expression:
let $irn :=
copy $c := ($collect//FIN)[1]
modify (
for $text in $c//text()
where string-length(normalize-space()) = 0
return delete node $text
)
return $cOr shorter:
let $irn := ($collect//FIN)[1] update (
delete node .//text()[not(normalize-space())]
)If this does not help, we'll probably need more information on the data you have stored in the database.
Best,
Christian
Quoted text · Adam Law · 47 lines
On Sat, May 30, 2015 at 9:29 AM, Adam Law <adamlaw at adamlaw.email> wrote: > I may be doing something wrong but <output:indent value='no'/> does not > appear to work with fn:serialize > > Adam > > > > let $ve_collectlocations := > <collections><collection>{$page:collection_main_private}</collection></collections> > > let $parameters := <output:serialization-parameters> > > <output:method value='xml'/> > > <output:indent value='no'/> > > <output:omit-xml-declaration value='yes'/> > > <output:encoding value='utf-8'/> > > </output:serialization-parameters> > > let $vs_result:= <Items>{for $collectlocation in > $ve_collectlocations//collection/text() > > for $collect in collection($collectlocation)/* > > for $deadline in $collect//Deadline/Open > > let $irn := ($collect//FIN)[1] > > let $xs_string:= > string(fn:serialize($collect,$parameters)) > > let $md5 := > <md5>{xs:hexBinary(hash:md5($xs_string))}</md5> > > let $vs_result := <Hit>{md5}</Hit> > > return $vs_result > > }</Items> > > return $vs_result > > };
Written for BaseX 8.2. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery