@@ -536,7 +536,7 @@ declare function setup:rewrite-config($import-configs as node()+, $silent as xs:
536
536
<groups xmlns = "http://marklogic.com/xdmp/group" >{
537
537
let $default-group := ($import-configs/self::*:configuration/@default-group , "Default" )[1 ]
538
538
for $group in fn:distinct-values ((
539
- $import-configs/descendant-or-self::gr:group /gr:group-name,
539
+ $import-configs/descendant-or-self::gr:group /gr:group-name/ fn:string () ,
540
540
$import-configs/descendant-or-self::*/(
541
541
self::gr:http-server, self::gr:xdbc-server,
542
542
self::gr:odbc-server, self::gr:task-server, self::db:database
@@ -559,7 +559,7 @@ declare function setup:rewrite-config($import-configs as node()+, $silent as xs:
559
559
let $databases := $import-configs/descendant-or-self::db:database[
560
560
@group = $group or ( $group = $default-group and fn:empty (@group ) )
561
561
]
562
- let $group-config := $import-configs/descendant-or-self::gr:group [gr:group-name = $group]
562
+ let $group-config := $import-configs/descendant-or-self::gr:group [gr:group-name/ fn:string () = $group]
563
563
where fn:exists ($servers | $databases | $group-config)
564
564
return
565
565
<group>
@@ -608,7 +608,7 @@ declare function setup:rewrite-config($import-configs as node()+, $silent as xs:
608
608
let $_ :=
609
609
if ($silent) then ()
610
610
else
611
- for $group in $config/gr:groups/gr:group /gr:group-name
611
+ for $group in $config/gr:groups/gr:group /gr:group-name/ fn:string ()
612
612
let $hosts := ($config/ho:hosts/ho:host[ho:group /@name = $group], try { xdmp:group-hosts (xdmp:group ($group)) } catch ($ignore) {})
613
613
where fn:empty ($hosts)
614
614
return
@@ -621,6 +621,43 @@ declare function setup:rewrite-config($import-configs as node()+, $silent as xs:
621
621
return if ($keep-comments) then $config else setup:suppress-comments ($config)
622
622
};
623
623
624
+ declare function setup:split-config ($config as element (configuration), $app-name as xs:string) as node ()* {
625
+ for $part in (
626
+ $config/*/*,
627
+ $config/gr:groups/gr:group /(
628
+ (gr:http-servers, gr:xdbc-servers, gr:odbc-servers)/*,
629
+ gr:task-server
630
+ )
631
+ )
632
+ let $type := fn:local-name ($part)
633
+
634
+ let $name :=
635
+ if ($part instance of element (gr:task-server)) then
636
+ "TaskServer"
637
+ else
638
+ $part/*[local-name () = ("name" , "forest-name" , "local-name" , concat ($type, "-name" ))][1 ]
639
+ /fn:replace (fn:replace (fn:string (), "^(.*/)?([^/]+)" , "$2" ), "^\$\{group\}$" , "default-group" )
640
+
641
+ let $path := fn:replace (fn:replace ($type, "(http|xdbc|odbc|task)-" , "" ) || "s" , "ys$" , "ies" )
642
+ let $path :=
643
+ if (fn:contains (fn:namespace-uri ($part), "security" )) then
644
+ "security/" || $path
645
+ else
646
+ fn:replace ($path, "assignments/" , "forests/" )
647
+
648
+ let $file := fn:replace ($name, "(@ml.|[${}])" , "" ) || ".xml"
649
+
650
+ return (
651
+ comment { "SAVE-PART-AS:" || $path || "/" || $file },
652
+ typeswitch ($part)
653
+ case element (gr:group )
654
+ return element gr:group {
655
+ $part/@*,
656
+ $part/(node () except (gr:http-servers, gr:xdbc-servers, gr:odbc-servers, gr:task-server))
657
+ }
658
+ default return $part
659
+ )
660
+ };
624
661
625
662
(:
626
663
base-name : Original forest base name - this should be the name from the config.
0 commit comments