-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathdo-not-use-transform
More file actions
35 lines (29 loc) · 1.2 KB
/
Copy pathdo-not-use-transform
File metadata and controls
35 lines (29 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# This script tranforms all *.xml files in the vocabularies folder into *.md and .json files
#
# Prerequisites
# - Java sudo apt-get install default-jre
# - Git sudo apt-get install git
# - Xalan 2.7.1 sudo apt-get install libxalan2-java
# - json_reformat sudo apt-get install yajl-tools
process() {
local name=${1##*/}; name=${name%.*}
echo $name
java -cp /usr/share/java/xalan2.jar org.apache.xalan.xslt.Process -L -XSL Vocab-to-MarkDown.xsl -IN $1 -OUT ../vocabularies/$name.md
git --no-pager diff --ignore-space-at-eol ../vocabularies/$name.md
java -cp /usr/share/java/xalan2.jar org.apache.xalan.xslt.Process -L -XSL V4-CSDL-normalize-Target.xsl -IN $1 -OUT $name.normalized.xml
java -cp /usr/share/java/xalan2.jar org.apache.xalan.xslt.Process -L -XSL V4-CSDL-to-JSON.xsl -IN $name.normalized.xml -OUT $name.json
json_reformat < $name.json > ../vocabularies/$name.json
if [ $? = 0 ]
then
rm $name.normalized.xml $name.json
git --no-pager diff --ignore-space-at-eol ../vocabularies/$name.json
fi
}
for file in ../vocabularies/*.xml
do
if [ -z "$1" ] || [ "$file" = "../vocabularies/Org.OData.$1.V1.xml" ]
then
process $file
fi
done