- Follow this guide to install
jq
- Install Python and
pip
if you haven't already - Install
yq
via pip by runningpip install yq
For the following recipes we will assume we have a map called map.xml
in our current working directory.
cat map.xml | xq '."rbl:kb".concept'
cat map.xml | xq '."rbl:kb".rel'
cat map.xml | xq '."rbl:kb".concinst'
cat map.xml | xq '."rbl:kb".relinst'
Facts are just conditionless relinst
tags.
cat map.xml | xq '."rbl:kb".relinst | map(select(.condition == null))'
The following gets all Country instances from the map.
cat map.xml | xq -r '."rbl:kb".concinst | .[] | select(."@type"=="Country")."@name"'
cat map.xml | xq '."rbl:kb".rel | map(select(.secondFormObject != null))'
Create CSV of relationships with rel name, subject, object, and second form object question wordings
cat map.xml | xq '."rbl:kb".rel | map(select(.secondFormObject != null)) | map([ ."@name", ."@subject", "@object", .secondFormObject ]) | .[] | @csv'
cat map.xml | xq '."rbl:kb".rel | map(select(.secondFormObject != null or .secondFormSubject != null or .firstForm != null)) | length'