Skip to content

Commit

Permalink
Parametrize get_namespaces.sh and set the required file path in the M…
Browse files Browse the repository at this point in the history
…akefile
  • Loading branch information
gkostkowski committed Sep 19, 2024
1 parent abde78b commit f4a9247
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ TURTLE_FILELIST=$(shell ls ${ONTOLOGY_FOLDER_PATH}/*.ttl)
# Widoco variables
WIDOCO_RDF_INPUT_FILE_PATH?=test/reasoning-investigation/model-2020-12-16/ePO_restrictions.rdf
WIDOCO_OUTPUT_FOLDER_PATH?=output/widoco
NAMESPACES_AS_RDFPIPE_ARGS=$(shell ${MODEL2OWL_FOLDER}/scripts/get_namespaces.sh)
NAMESPACES_XML_FILE_PATH?=${MODEL2OWL_FOLDER}/test/ePO-default-config/namespaces.xml
NAMESPACES_AS_RDFPIPE_ARGS=$(shell ${MODEL2OWL_FOLDER}/scripts/get_namespaces.sh ${NAMESPACES_XML_FILE_PATH})
RDF_XML_MIME_TYPE:='application/rdf+xml'
TURTLE_MIME_TYPE:='turtle'

Expand Down
22 changes: 15 additions & 7 deletions scripts/get_namespaces.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
#!/bin/bash
#
# Gets namespaces from namespaces.xml file and prepares argument
# list from them to be used with `rdfpipe` tool.
# Uses Saxon installed in the project main directory.
# Gets namespaces from an XML file with the model2owl project namespaces
# (`namespaces.xml` by default) and prepares argument list from them to be
# used with `rdfpipe` tool. Uses Saxon installed in the project main directory.
#
# USAGE: get_namespaces.sh NAMESPACES_XML_FILE_PATH

if [ -z "$1" ]; then
echo "ERROR: path to *.xml file with namespaces not given."
exit 1
fi
namespaces_file_path="$1"

PROJECT_DIR=$(dirname $(dirname $(realpath ${BASH_SOURCE[0]})))
NAMESPACES_DIR=${PROJECT_DIR}/test/ePO-default-config
namespaces_file_dir=$(dirname $(realpath $namespaces_file_path))
namespaces_file_name=$(basename $namespaces_file_path)

cd ${NAMESPACES_DIR}
cd ${namespaces_file_dir}
namespaces=$(
java -cp ../../saxon/saxon.jar net.sf.saxon.Query -s:namespaces.xml \
java -cp ../../saxon/saxon.jar net.sf.saxon.Query -s:${namespaces_file_name} \
-qs:'for $x in /*:prefixes/*:prefix return concat(string($x/@name), "=", string($x/@value))' \
\!method=text
)
Expand Down

0 comments on commit f4a9247

Please sign in to comment.