@@ -654,7 +654,7 @@ declare function setup:rewrite-config($import-configs as node()+, $properties as
654654
655655 let $default-group := ($import-configs/self::*:configuration/@default-group , "Default" )[1 ]
656656 for $group in fn:distinct-values ((
657- $import-configs/descendant-or-self::gr:group /gr:group-name,
657+ $import-configs/descendant-or-self::gr:group /gr:group-name/ fn:string () ,
658658 $import-configs/descendant-or-self::*/(
659659 self::gr:http-server, self::gr:xdbc-server,
660660 self::gr:odbc-server, self::gr:task-server, self::db:database
@@ -677,7 +677,7 @@ declare function setup:rewrite-config($import-configs as node()+, $properties as
677677 let $databases := $import-configs/descendant-or-self::db:database[
678678 @group = $group or ( $group = $default-group and fn:empty (@group ) )
679679 ]
680- let $group-config := $import-configs/descendant-or-self::gr:group [gr:group-name = $group]
680+ let $group-config := $import-configs/descendant-or-self::gr:group [gr:group-name/ fn:string () = $group]
681681 where fn:exists ($servers | $databases | $group-config)
682682 return
683683 <group>
@@ -726,7 +726,7 @@ declare function setup:rewrite-config($import-configs as node()+, $properties as
726726 let $_ :=
727727 if ($silent) then ()
728728 else
729- for $group in $config/gr:groups/gr:group /gr:group-name
729+ for $group in $config/gr:groups/gr:group /gr:group-name/ fn:string ()
730730 let $hosts := ($config/ho:hosts/ho:host[ho:group /@name = $group], try { xdmp:group-hosts (xdmp:group ($group)) } catch ($ignore) {})
731731 where fn:empty ($hosts)
732732 return
@@ -741,6 +741,43 @@ declare function setup:rewrite-config($import-configs as node()+, $properties as
741741 )
742742};
743743
744+ declare function setup:split-config ($config as element (configuration), $app-name as xs:string) as node ()* {
745+ for $part in (
746+ $config/*/*,
747+ $config/gr:groups/gr:group /(
748+ (gr:http-servers, gr:xdbc-servers, gr:odbc-servers)/*,
749+ gr:task-server
750+ )
751+ )
752+ let $type := fn:local-name ($part)
753+
754+ let $name :=
755+ if ($part instance of element (gr:task-server)) then
756+ "TaskServer"
757+ else
758+ $part/*[local-name () = ("name" , "forest-name" , "local-name" , concat ($type, "-name" ))][1 ]
759+ /fn:replace (fn:replace (fn:string (), "^(.*/)?([^/]+)" , "$2" ), "^\$\{group\}$" , "default-group" )
760+
761+ let $path := fn:replace (fn:replace ($type, "(http|xdbc|odbc|task)-" , "" ) || "s" , "ys$" , "ies" )
762+ let $path :=
763+ if (fn:contains (fn:namespace-uri ($part), "security" )) then
764+ "security/" || $path
765+ else
766+ fn:replace ($path, "assignments/" , "forests/" )
767+
768+ let $file := fn:replace ($name, "(@ml.|[${}])" , "" ) || ".xml"
769+
770+ return (
771+ comment { "SAVE-PART-AS:" || $path || "/" || $file },
772+ typeswitch ($part)
773+ case element (gr:group )
774+ return element gr:group {
775+ $part/@*,
776+ $part/(node () except (gr:http-servers, gr:xdbc-servers, gr:odbc-servers, gr:task-server))
777+ }
778+ default return $part
779+ )
780+ };
744781
745782(:
746783 base-name : Original forest base name - this should be the name from the config.
0 commit comments