<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.art-decor.org/index.php?action=history&amp;feed=atom&amp;title=Update_name_based_refs_xquery</id>
	<title>Update name based refs xquery - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.art-decor.org/index.php?action=history&amp;feed=atom&amp;title=Update_name_based_refs_xquery"/>
	<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;action=history"/>
	<updated>2026-05-20T05:42:47Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.0</generator>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7330&amp;oldid=prev</id>
		<title>Ahenket at 06:40, 17 June 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7330&amp;oldid=prev"/>
		<updated>2020-06-17T06:40:03Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:40, 17 June 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors when not that sophisticated a lot of hand editing was required. Name based references were a way to make the DECOR files friendlier. However: there is no guarantee that names are unique across projects and it quickly became clear they are ambiguous and have no future.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors when not that sophisticated a lot of hand editing was required. Name based references were a way to make the DECOR files friendlier. However: there is no guarantee that names are unique across projects and it quickly became clear they are ambiguous and have no future.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note: &amp;#039;&amp;#039;&amp;#039;once applied to your project, there is no undo&amp;#039;&amp;#039;&amp;#039; unless you keep a copy of the project as backup.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Note: &amp;#039;&amp;#039;&amp;#039;once applied to your project, there is no undo&amp;#039;&amp;#039;&amp;#039; unless you keep a copy of the project&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;/all projects &lt;/ins&gt;as backup.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This xquery will perform the following actions:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This xquery will perform the following actions:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l104&quot; &gt;Line 104:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 104:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;};&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;};&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;let $projectPrefix&amp;#160; := &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;()&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;let $projectPrefix&amp;#160; := &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;&amp;#039;demo1-&amp;#039;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;let $decors&amp;#160; &amp;#160; &amp;#160; &amp;#160;  := &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;let $decors&amp;#160; &amp;#160; &amp;#160; &amp;#160;  := &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (empty($projectPrefix)) &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&amp;#160; &amp;#160; if (empty($projectPrefix)) &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ahenket</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7329&amp;oldid=prev</id>
		<title>Ahenket at 06:39, 17 June 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7329&amp;oldid=prev"/>
		<updated>2020-06-17T06:39:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 06:39, 17 June 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors when not that sophisticated a lot of hand editing was required. Name based references were a way to make the DECOR files friendlier. However: there is no guarantee that names are unique across projects and it quickly became clear they are ambiguous and have no future.&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors when not that sophisticated a lot of hand editing was required. Name based references were a way to make the DECOR files friendlier. However: there is no guarantee that names are unique across projects and it quickly became clear they are ambiguous and have no future.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note: &amp;#039;&amp;#039;&amp;#039;once applied to your project, there is no undo&amp;#039;&amp;#039;&amp;#039; unless you keep a copy of the project as backup.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This xquery will perform the following actions:&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This xquery will perform the following actions:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Ahenket</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7326&amp;oldid=prev</id>
		<title>Ahenket: Created page with &quot;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors wh...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.art-decor.org/index.php?title=Update_name_based_refs_xquery&amp;diff=7326&amp;oldid=prev"/>
		<updated>2020-06-17T06:06:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors wh...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;For updating name based references to id based based references in a DECOR project or the entire server. Name based references used to be supported because when the editors when not that sophisticated a lot of hand editing was required. Name based references were a way to make the DECOR files friendlier. However: there is no guarantee that names are unique across projects and it quickly became clear they are ambiguous and have no future.&lt;br /&gt;
&lt;br /&gt;
This xquery will perform the following actions:&lt;br /&gt;
* Lookup name based references to templates and valueSets&lt;br /&gt;
* Lookup the target object and, if only 1 is found update the name based reference to an id based reference&lt;br /&gt;
* If multiple are found, this is included in the final report for you to decide&lt;br /&gt;
* The variable &amp;lt;code&amp;gt;$execute&amp;lt;/code&amp;gt; which is false() by default allows you to first assess what the situation is before changing anything&lt;br /&gt;
To run the xquery below on the server:&lt;br /&gt;
{{:run xquery}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot; enclose=&amp;quot;div&amp;quot;&amp;gt;&lt;br /&gt;
import module namespace get      = &amp;quot;http://art-decor.org/ns/art-decor-settings&amp;quot; at &amp;quot;xmldb:exist:///db/apps/art/modules/art-decor-settings.xqm&amp;quot;;&lt;br /&gt;
import module namespace art      = &amp;quot;http://art-decor.org/ns/art&amp;quot; at &amp;quot;xmldb:exist:///db/apps/art/modules//art-decor.xqm&amp;quot;;&lt;br /&gt;
import module namespace vs       = &amp;quot;http://art-decor.org/ns/decor/valueset&amp;quot; at &amp;quot;xmldb:exist:///db/apps/art/api/api-decor-valueset.xqm&amp;quot;;&lt;br /&gt;
import module namespace templ    = &amp;quot;http://art-decor.org/ns/decor/template&amp;quot; at &amp;quot;xmldb:exist:///db/apps/art/api/api-decor-template.xqm&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
(: set to true if you want name based references replaced with oid based references :)&lt;br /&gt;
declare variable $execute as xs:boolean  := false();&lt;br /&gt;
&lt;br /&gt;
declare function local:replaceWithOidTemplate($el as element()) {&lt;br /&gt;
    let $prefix := $el/ancestor::decor/project/@prefix&lt;br /&gt;
    let $ref    := $el/(@contains|@ref|@template|@valueSet)&lt;br /&gt;
    let $flex   := if ($el/@flexibility) then $el/@flexibility else &amp;#039;dynamic&amp;#039;&lt;br /&gt;
    let $obj    := templ:getTemplateByRef($ref, $flex, $prefix)/template/template[@id]&lt;br /&gt;
    let $upd1   := &amp;lt;current ref=&amp;quot;{$ref}&amp;quot; flexibility=&amp;quot;{$flex}&amp;quot;/&amp;gt;&lt;br /&gt;
    let $upd2   := &lt;br /&gt;
        if (matches($ref,&amp;#039;^[0-9\.]+$&amp;#039;) or count($obj) != 1) then (false()) else (&lt;br /&gt;
            let $update := if ($execute) then (update insert comment {concat($ref/name(),&amp;#039; name=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot;&amp;#039;)} preceding $ref/parent::*) else ()&lt;br /&gt;
            let $update := if ($execute) then (update value $ref with $obj/@id) else ()&lt;br /&gt;
            return true()&lt;br /&gt;
        )&lt;br /&gt;
    (:let $upd3   :=&lt;br /&gt;
        if ($el/@flexibility=&amp;#039;dynamic&amp;#039;) then (&lt;br /&gt;
            let $ref := if ($execute) then (update delete $el/@flexibility) else ()&lt;br /&gt;
            return true()&lt;br /&gt;
        ) else (false()):)&lt;br /&gt;
    &lt;br /&gt;
    return&lt;br /&gt;
        element {name($el)} {&lt;br /&gt;
            attribute currentRef {$upd1/@ref},&lt;br /&gt;
            attribute currentFlex {$upd1/@flexibility},&lt;br /&gt;
            if ($upd2=false()) then () else (attribute newRef {$obj/@id}),&lt;br /&gt;
            (:if ($upd3=false()) then () else (attribute newFlex {&amp;#039;dynamic&amp;#039;}),:)&lt;br /&gt;
            &amp;lt;text&amp;gt;&lt;br /&gt;
            {&lt;br /&gt;
                (:if ($upd2=true() and $upd3=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. New value: @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$obj/@id,&amp;#039;&amp;quot; and @flexibility=&amp;quot;dynamic&amp;quot; has been removed.&amp;#039;)&lt;br /&gt;
                else :)if ($upd2=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. New value: @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,string-join(distinct-values($obj/@id),&amp;#039; &amp;#039;),&amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
                (:else if ($upd3=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. Attribute @flexibility=&amp;quot;dynamic&amp;quot; has been removed.&amp;#039;):)&lt;br /&gt;
                else if (count($obj) &amp;gt; 1) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. However multiple objects were found (&amp;#039;,count($obj),&amp;#039;, so no change was applied.&amp;#039;)&lt;br /&gt;
                else (&lt;br /&gt;
                    concat(name($el), &amp;#039; element does not need any change&amp;#039;)&lt;br /&gt;
                )&lt;br /&gt;
            }&lt;br /&gt;
            &amp;lt;/text&amp;gt;&lt;br /&gt;
        }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
declare function local:replaceWithOidValueSet($el as element()) {&lt;br /&gt;
    let $prefix := $el/ancestor::decor/project/@prefix&lt;br /&gt;
    let $ref    := $el/(@contains|@ref|@template|@valueSet)&lt;br /&gt;
    let $flex   := if ($el/@flexibility) then $el/@flexibility else &amp;#039;dynamic&amp;#039;&lt;br /&gt;
    let $obj    := vs:getValueSetByRef($ref, $flex, $prefix)//valueSet[@id]&lt;br /&gt;
    let $upd1   := &amp;lt;current ref=&amp;quot;{$ref}&amp;quot; flexibility=&amp;quot;{$flex}&amp;quot;/&amp;gt;&lt;br /&gt;
    let $upd2   := &lt;br /&gt;
        if (matches($ref,&amp;#039;^[0-9\.]+$&amp;#039;) or count($obj) != 1) then (false()) else (&lt;br /&gt;
            let $update := if ($execute) then (update insert comment {concat($ref/name(),&amp;#039; name=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot;&amp;#039;)} preceding $ref/parent::*) else ()&lt;br /&gt;
            let $update := if ($execute) then (update value $ref with $obj/@id) else ()&lt;br /&gt;
            return true()&lt;br /&gt;
        )&lt;br /&gt;
    (:let $upd3   :=&lt;br /&gt;
        if ($el/@flexibility=&amp;#039;dynamic&amp;#039; and count($obj) = 1) then (&lt;br /&gt;
            let $ref := if ($execute) then (update delete $el/@flexibility) else ()&lt;br /&gt;
            return true()&lt;br /&gt;
        ) else (false()):)&lt;br /&gt;
    &lt;br /&gt;
    return&lt;br /&gt;
        element {name($el)} {&lt;br /&gt;
            attribute currentRef {$upd1/@ref},&lt;br /&gt;
            attribute currentFlex {$upd1/@flexibility},&lt;br /&gt;
            if ($upd2=false()) then () else (attribute newRef {$obj/@id}),&lt;br /&gt;
            (:if ($upd3=false()) then () else (attribute newFlex {&amp;#039;dynamic&amp;#039;}),:)&lt;br /&gt;
            &amp;lt;text&amp;gt;&lt;br /&gt;
            {&lt;br /&gt;
                (:if ($upd2=true() and $upd3=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. New value: @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$obj/@id,&amp;#039;&amp;quot; and @flexibility=&amp;quot;dynamic&amp;quot; has been removed.&amp;#039;)&lt;br /&gt;
                else :)if ($upd2=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. New value: @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,string-join(distinct-values($obj/@id),&amp;#039; &amp;#039;),&amp;#039;&amp;quot;&amp;#039;)&lt;br /&gt;
                (:else if ($upd3=true()) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. Attribute @flexibility=&amp;quot;dynamic&amp;quot; has been removed.&amp;#039;):)&lt;br /&gt;
                else if (count($obj) &amp;gt; 1) then&lt;br /&gt;
                    concat(name($el), &amp;#039; element currently has @&amp;#039;, name($ref), &amp;#039;=&amp;quot;&amp;#039;,$ref,&amp;#039;&amp;quot; and @flexibility=&amp;quot;&amp;#039;,$flex,&amp;#039;&amp;quot;. However multiple objects were found (&amp;#039;,count($obj),&amp;#039;, so no change was applied.&amp;#039;)&lt;br /&gt;
                else (&lt;br /&gt;
                    concat(name($el), &amp;#039; element does not need any change&amp;#039;)&lt;br /&gt;
                )&lt;br /&gt;
            }&lt;br /&gt;
            &amp;lt;/text&amp;gt;&lt;br /&gt;
        }&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
let $projectPrefix  := ()&lt;br /&gt;
let $decors         := &lt;br /&gt;
    if (empty($projectPrefix)) &lt;br /&gt;
    then $get:colDecorData//decor &lt;br /&gt;
    else $get:colDecorData//decor[project/@prefix=$projectPrefix]&lt;br /&gt;
&lt;br /&gt;
return&lt;br /&gt;
    &amp;lt;x execute=&amp;quot;{$execute}&amp;quot;&amp;gt;&lt;br /&gt;
    {&lt;br /&gt;
        for $ref in ( $decors//*[@valueSet] )&lt;br /&gt;
        return&lt;br /&gt;
            local:replaceWithOidValueSet($ref)&lt;br /&gt;
        ,&lt;br /&gt;
        for $ref in ( $decors//transaction/representingTemplate[@ref] | &lt;br /&gt;
                      $decors//relationship[@ref][parent::template][not(ancestor::example)] | &lt;br /&gt;
                      $decors//element[@contains][ancestor::template][not(ancestor::example)] | &lt;br /&gt;
                      $decors//include[@ref][ancestor::template][not(ancestor::example)] &lt;br /&gt;
                    )&lt;br /&gt;
        return&lt;br /&gt;
            local:replaceWithOidTemplate($ref)&lt;br /&gt;
    }&lt;br /&gt;
    &amp;lt;/x&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[category:xqueries]]&lt;/div&gt;</summary>
		<author><name>Ahenket</name></author>
		
	</entry>
</feed>