|
declare namespace xsi = "http://www.w3.org/2001/XMLSchema-instance";
|
|
|
|
declare function local:out_root_x_c($top as node(),$out_root_x,$out_root_x_i,$out_root,$out_root_i)
|
|
{
|
|
|
|
for $out_root_x_c at $out_root_x_c_i in let $inVar := $out_root_x/c return $inVar
|
|
return (
|
|
|
|
if ( fn:not (( fn:exists($out_root_x_c[@xsi:nil]))) )
|
|
then (
|
|
element c {
|
|
let $opt := (
|
|
|
|
let $unconvertedValue := (
|
|
let $mapElemRef := $out_root_x_c/c1[1]
|
|
return (
|
|
if (fn:count($mapElemRef) = 0) then ('_789odtMissing') else (
|
|
if ($mapElemRef/@xsi:nil['true']) then ('_osdt987Null') else ($mapElemRef/text()))
|
|
)
|
|
) return if ( $unconvertedValue[1] cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
|
|
)
|
|
return if ($opt[last()] cast as xs:string? = '_789odtMissing') then () else if (fn:string-length(fn:string-join($opt[last()],'')) > 0) then
|
|
element c1 { $opt
|
|
}
|
|
else () ,
|
|
let $opt := (
|
|
|
|
let $unconvertedValue := (
|
|
let $mapElemRef := $out_root_x_c/c2[1]
|
|
return (
|
|
if (fn:count($mapElemRef) = 0) then ('_789odtMissing') else (
|
|
if ($mapElemRef/@xsi:nil['true']) then ('_osdt987Null') else ($mapElemRef/text()))
|
|
)
|
|
) return if ( $unconvertedValue[1] cast as xs:string? = '_osdt987Null') then () else text { $unconvertedValue }
|
|
)
|
|
return if ($opt[last()] cast as xs:string? = '_789odtMissing') then () else if (fn:string-length(fn:string-join($opt[last()],'')) > 0) then
|
|
element c2 { $opt
|
|
}
|
|
else ()
|
|
}
|
|
) else (
|
|
element c { attribute xsi:nil { 'true' }
|
|
})
|
|
)
|
|
};
|
|
|
|
|
|
|
|
declare function local:out_root_x($top as node(),$out_root,$out_root_i)
|
|
{
|
|
|
|
for $out_root_x at $out_root_x_i in $out_root/x
|
|
group by $out_root_x_group_by := fn:data($out_root_x/c)[1]
|
|
where fn:exists($out_root_x_group_by)
|
|
let $out_root_x_group := $out_root_x
|
|
let $out_root_x := $out_root_x[1]
|
|
order by $out_root_x_group_by
|
|
return (
|
|
|
|
|
|
if ( fn:not (( fn:exists($out_root_x[@xsi:nil]))) )
|
|
then (
|
|
element x {
|
|
let $opt := (
|
|
|
|
let $unconvertedValue := (
|
|
let $mapElemRef := $out_root_x/a[1]
|
|
return (
|
|
if (fn:count($mapElemRef) = 0) then ('_789odtMissing') else (
|
|
if ($mapElemRef/@xsi:nil['true']) then ('_osdt987Null') else ($mapElemRef/text()))
|
|
)
|
|
) return if ( $unconvertedValue[1] cast as xs:string? = '_osdt987Null') then $unconvertedValue else text { $unconvertedValue }
|
|
)
|
|
return if ($opt[last()] cast as xs:string? = '_osdt987Null') then (
|
|
element a { attribute xsi:nil { 'true' }
|
|
}) else if ($opt[last()] cast as xs:string? = '_789odtMissing') then () else if (fn:string-length(fn:string-join($opt[last()],'')) > 0) then
|
|
element a { $opt
|
|
}
|
|
else () ,
|
|
let $opt := (
|
|
|
|
let $unconvertedValue := (
|
|
let $mapElemRef := $out_root_x/b[1]
|
|
return (
|
|
if (fn:count($mapElemRef) = 0) then ('_789odtMissing') else (
|
|
if ($mapElemRef/@xsi:nil['true']) then ('_osdt987Null') else ($mapElemRef/text()))
|
|
)
|
|
) return if ( $unconvertedValue[1] cast as xs:string? = '_osdt987Null') then $unconvertedValue else text { $unconvertedValue }
|
|
)
|
|
return if ($opt[last()] cast as xs:string? = '_osdt987Null') then (
|
|
element b { attribute xsi:nil { 'true' }
|
|
}) else if ($opt[last()] cast as xs:string? = '_789odtMissing') then () else if (fn:string-length(fn:string-join($opt[last()],'')) > 0) then
|
|
element b { $opt
|
|
}
|
|
else () , local:out_root_x_c($top,$out_root_x,$out_root_x_i,$out_root,$out_root_i)
|
|
|
|
}
|
|
) else (
|
|
element x { attribute xsi:nil { 'true' }
|
|
})
|
|
)
|
|
};
|
|
|
|
|
|
|
|
declare function local:out_root($top as node())
|
|
{
|
|
|
|
for $out_root at $out_root_i in let $inVar := $top/root return $inVar
|
|
return (
|
|
element root { (), local:out_root_x($top,$out_root,$out_root_i)
|
|
|
|
}
|
|
)
|
|
};
|
|
|
|
|
|
local:out_root(/)
|