Skip to content

Commit dec27d8

Browse files
committed
Add namespace utils
1 parent 47732e0 commit dec27d8

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

xsd/dmn-namespace-utils.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
DMN11='http://www.omg.org/spec/DMN/20151101/dmn.xsd'
4+
DMN12='http://www.omg.org/spec/DMN/20180521/MODEL/'
5+
DMN13='https://www.omg.org/spec/DMN/20191111/MODEL/'
6+
DMN14='https://www.omg.org/spec/DMN/20211108/MODEL/'
7+
DMNDI11='http://www.omg.org/spec/DMN/20151101/DMNDI'
8+
DMNDI12='http://www.omg.org/spec/DMN/20180521/DMNDI/'
9+
DMNDI13='https://www.omg.org/spec/DMN/20191111/DMNDI/'
10+
DI='http://www.omg.org/spec/DMN/20180521/DI/'
11+
DC='http://www.omg.org/spec/DMN/20180521/DC/'
12+
FEEL10='http://www.omg.org/spec/FEEL/20140401'
13+
FEEL12='http://www.omg.org/spec/DMN/20180521/FEEL/'
14+
FEEL13='https://www.omg.org/spec/DMN/20191111/FEEL/'
15+
FEEL14='https://www.omg.org/spec/DMN/20211108/FEEL/'

xsd/migrate-to-new-namespaces.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -euxo pipefail
3+
4+
XSD_DIR="$(dirname $0)"
5+
6+
source "$XSD_DIR/dmn-namespace-utils.sh"
7+
8+
find_dmn13_files() {
9+
grep -Hirl $DMN13 --exclude='*.biodi.dmn' --exclude='test-xsd*' --exclude='dmn-namespace-utils.sh' --exclude='migrate-to-new-namespaces.sh' --exclude='DMN13.xsd' --exclude-dir=.git --exclude-dir=target
10+
}
11+
12+
#find_dmn13_files
13+
14+
# (grep -Hirl 'http://www.omg.org/spec/DMN/20151101/dmn.xsd' --exclude='*.biodi.dmn' --exclude='test-xsd*' --exclude='migrate-to-new-namespaces.sh' --exclude='DMN12.xsd' && find -iname '*.xsd') | xargs sed -i \
15+
# -e 's#http://www.omg.org/spec/DMN/20151101/dmn.xsd#http://www.omg.org/spec/DMN/20180521/MODEL/#' \
16+
# -e 's#http://www.omg.org/spec/DMN/20151101/DMNDI#http://www.omg.org/spec/DMN/20180521/DMNDI/#' \
17+
# -e 's#http://www.omg.org/spec/DMN/20151101/DI#http://www.omg.org/spec/DMN/20180521/DI/#' \
18+
# -e 's#http://www.omg.org/spec/DMN/20151101/DC#http://www.omg.org/spec/DMN/20180521/DC/#' \
19+
# -e 's#http://www.omg.org/spec/FEEL/20140401#http://www.omg.org/spec/DMN/20180521/FEEL/#'
20+
21+
# (grep -Hirl 'http://www.omg.org/spec/DMN/20151101/dmn.xsd' --exclude '*.biodi.dmn' --exclude='test-xsd*' && find -iname '*.xsd') | xargs sed -i \
22+
# -e 's#http://www.omg.org/spec/DMN/20151101/dmn.xsd#http://www.omg.org/spec/DMN/20180521/DMN12.xsd#' \
23+
# -e 's#http://www.omg.org/spec/DMN/20151101/DMNDI#http://www.omg.org/spec/DMN/20180521/DMNDI12.xsd#' \
24+
# -e 's#http://www.omg.org/spec/DMN/20151101/DI#http://www.omg.org/spec/DMN/20180521/DI.xsd#' \
25+
# -e 's#http://www.omg.org/spec/DMN/20151101/DC#http://www.omg.org/spec/DMN/20180521/DC.xsd#'
26+
27+
# grep -Hirl 'http://www.omg.org/spec/FEEL/20140401' --exclude=DMN11.xsd --exclude='migrate-to-new-namespaces.sh'
28+
# grep -Hirl 'http://www.omg.org/spec/FEEL/20140401' --exclude=DMN11.xsd --exclude='migrate-to-new-namespaces.sh' | xargs sed -i -e 's#http://www.omg.org/spec/FEEL/20140401#http://www.omg.org/spec/DMN/20180521/FEEL/#'
29+
30+
upgrade_dmn_13_to_dmn_14() {
31+
sed \
32+
-e "s#$DMN13#$DMN14#g" \
33+
-e "s#$FEEL13#$FEEL14#g" \
34+
"$1"
35+
}
36+
37+
# recursively search all DMN files in the current directory and perform a schema validation with the DMN 1.1 and 1.2 schemas
38+
declare -i NUMBER_OF_FILES=0
39+
while IFS= read -r -d '' DMN_FILE; do
40+
NUMBER_OF_FILES+=1
41+
#echo "$NUMBER_OF_FILES: $DMN_FILE"
42+
upgrade_dmn_13_to_dmn_14 "$DMN_FILE" | sponge "$DMN_FILE"
43+
done < <(find . '(' -iname '*.dmn*.xml' -o -iname '*.dmn' ')' -type f -print0)

0 commit comments

Comments
 (0)