Closed andylolz closed 3 years ago
Interesting, thanks @andylolz
In terms of knowing the default vocabulary, my understanding is that this must be something you've inferred from the standard, as it's not a flat or explicit reference? If so, did you make a lookup table, or similar? It strikes me that would be a useful resource for the standard/users
In terms of knowing the default vocabulary, my understanding is that this must be something you've inferred from the standard, as it's not a flat or explicit reference? If so, did you make a lookup table, or similar? It strikes me that would be a useful resource for the standard/users
Good question, @stevieflow! Apologies in advance for the very long answer…
There’s a mapping.xml file that is part of the Single Source of Truth (it lives in the IATI-Codelists repository), and defines the relationship between IATI attributes and IATI codelists. The dashboard and reference site both use this mapping file.
For instance, the mapping file states that iati-activity/recipient-country/@code
should always contain a value from the Country
codelist (ref):
<mapping>
<path>//iati-activity/recipient-country/@code</path>
<codelist ref="Country" />
</mapping>
When the code used depends on the @vocabulary
, the mapping includes a condition
element. For instance, the CashandVoucherModalities
codelist can be used for iati-activity/default-aid-type/@code
, but only when iati-activity/default-aid-type/@vocabulary
is set to "4" (ref):
<mapping>
<path>//iati-activity/default-aid-type/@code</path>
<codelist ref="CashandVoucherModalities" />
<condition>@vocabulary = '4'</condition>
</mapping>
In cases where multiple vocabularies can be used, there’s usually a default vocabulary. So for example, if no iati-activity/default-aid-type/@vocabulary
is declared, the default vocabulary for iati-activity/default-aid-type/@code
is the AidType
codelist. This is shown in the mapping file by a not(@vocabulary)
condition (ref):
<mapping>
<path>//iati-activity/default-aid-type/@code</path>
<codelist ref="AidType" />
<condition>@vocabulary = '1' or not(@vocabulary)</condition>
</mapping>
So this pull request ensures the dahboard preferentially uses these default vocabularies (shown by a not(@vocabulary)
condition) over any non-default vocabularies.
Doesn’t look like this will be merged; closing.
The problem
Some attributes can contain values from different codelists, depending on the
@vocabulary
used. The dashboard doesn’t have a means of showing this, as per the yellow banner shown on dashboard codelists, and #174.Given the dashboard doesn’t have the functionality to select from multiple vocabularies, it needs to choose which vocabulary to use. Where a default vocabulary exists, it seems to make sense to prefer that one. That doesn’t necessarily happen at the moment, so this PR fixes that.
So for example, in the case of
iati-activity/sector/@code
, the default vocabulary isSector
. However, the dashboard currently uses the SectorCategory vocabulary:Similarly (as reported in #567),![Screenshot 2019-11-23 at 14 27 26](https://user-images.githubusercontent.com/464193/69480226-85bf1180-0dfd-11ea-9058-13fb911ff7f1.png)
iati-activity/default-aid-type/@code
uses the AidType vocabulary by default. However, the dashboard currently uses the (rarely used) CashAndVoucherModalities vocabulary:The proposed solution
This PR ensures that when a default vocabulary exists for a given attribute, it is preferred on dashboard codelist pages.
For![Screenshot 2019-11-23 at 14 30 28](https://user-images.githubusercontent.com/464193/69480257-d20a5180-0dfd-11ea-95b6-b4e73d480e89.png)
iati-activity/sector/@code
, that’s Sector:For![Screenshot 2019-11-23 at 14 31 27](https://user-images.githubusercontent.com/464193/69480269-f6662e00-0dfd-11ea-9e6a-bd012c0db19a.png)
iati-activity/default-aid-type/@code
, that’s AidType:It’s worth noting that for a small number of IATI attributes, there is no default codelist. For example,
iati-activity/tag/@code
. In such cases, we use the codelist for the first mapping for that attribute found in the mapping file.Fixes #567.