Gebruiksaanwijzing extensie External Data
Je vindt hier de officiële gebruiksaanwijzing van de Extension:External_Data.
De extensie werkt in twee stappen:
- Laad de gegevens uit externe bron
- Geef de gegevens weer op de pagina (of: sla de gegevens op met behulp van Semantic MediaWiki)
External Data biedt vijf verschillende manieren om externe gegevens in je wiki-pagina te laden:
<!-- Vanaf een webpagina, inclusief API -->
{{#get_web_data: }}
{{#get_soap_data: }}
<!-- Vanuit een locale file -->
{{#get_file_data: }}
<!-- Vanuit een database -->
{{#get_db_data: }}
<!-- Vanuit een LDAP-server -->
{{#get_ldap_data: }}
Voor het weergeven zijn de volgende opties beschikbaar:
<!-- Geef een waarde van een variabele weer -->
{{#external_value: }}
<!-- cycles through all the values retrieved for a set of variables, displaying the same "container" text for each one. -->
{{#for_external_table: }}
<!-- cycles through a table of values, storing them as semantic data via the Semantic MediaWiki extension, by mimicking a call to SMW's #subobject function for each row. -->
{{#store_external_table: }}
<!-- cycles through all the values retrieved for a set of variables, displaying each "row" using a template. -->
{{#display_external_table: }}
Een laatste commando is beschikbaar voor het wissen van gegevens:
<!--erases the current set of retrieved data -->
{{#clear_external_data: }}
Inhoud
Externe data vanaf een webpagina
{{#get_web_data:
url=data source URL
|format={CSV|CSV with header|GFF|JSON|XML}
|delimiter=delimiter
|data=local_variable_name1=external_variable_name1, etc.
|filters=external_variable_name1=filter_value1, etc.
|use xpath
|post data=additional data
|cache seconds=number of seconds
}}
SOAP
{{#get_soap_data:
url=data source URL
|request=the function used to request data
|requestData=parameter1=value1, etc.
|response=the function used to retrieve data
|data=local_variable_name1=external_variable_name1, etc.
}}
Externe data vanuit een database
Externe data vanuit een LDAP server
Testcase 1 - Gebruik External Data via de API van adlib
Documentatie adlib: [1]
Voorbeeld: Search all records: return all records from collect.inf
Specificatie API-verzoek:http://test2.adlibsoft.com/api/wwwopac.ashx?database=collect.inf&search=all
Code External Data:
{{#get_web_data:
url=http://test2.adlibsoft.com/api/wwwopac.ashx?database=collect.inf&search=all
|format=XML
|delimiter=10
|data=creatie=created,
modificatie=modification,
geselecteerd=selected,
administratie naam=administration_name,
maker=creator,
categorie=object_category,
object nummer=object_number,
reproductiereferentie=reproduction.reference,
titel=title,
taal=lang,
invariant=invariant
|cache seconds=1500
}}
Opmerkingen:
- Het attribuut / label (attribute, tag) priref is weggelaten, omdat het dubbel voorkomt. Het gebruik Xpath kan hiervoor een oplossing bieden.
- Het importeren van de letter à - geen ASCII-character - geeft een fout, veroorzaakt door het ontbreken van de multibyte string PHP-extensie (zie: http://php.net/manual/en/book.mbstring.php).
Error: No contents found at URL http://test2.adlibsoft.com/api/wwwopac.ashx?database=collect.inf&search=all.
| Creatie | Modificatie | Geselec teerd |
Administra tienaam |
Maker | Categorie | Object nummer | Reproductie referentie |
Titel | Taal |
|---|
Testccase 2 - Gebruik External Data om gegevens uit Wikidata via API op te halen
Documentatie:
- https://www.wikidata.org/w/api.php?action=help&modules=wbgetentities
- https://www.mediawiki.org/wiki/Wikibase/API#wbgetclaims
Voorbeeld labels
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q2155935&props=labels&languages=nl
Gebruik External data om het "label" (naam van de pagina op Wikipedia ?) op te vragen van het item "Q2155935" in Wikidata.org:
{{#get_web_data: url=https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q2155935&props=labels&languages=nl
&format=json
|format=JSON
|data= wikilabel=value
}}
{{#external_value:wikilabel}}
Error: No contents found at URL https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q2155935&props=labels&languages=nl &format=json. Resultaat: '
Alternatief (beter?) is het gebruik "?action=query"
Error: No contents found at URL https://www.wikidata.org/w/api.php?action=query&prop=wbgetentities&ids=Q2155935&languages=nl &format=json.
Resultaat: '
Resultaat lijkt goed, maar query werkt niet en geeft fouten.
api.php?action=query&prop=wbentityusage&titles=Main%20Page|Malayan%20civet
Voorbeeld Aliases
| Aliases |
|---|
| Vlaams Cultuurhuis |
| Brakke Grond |
| Nes 43-49, Amsterdam |
Voorbeeld "Claims"
https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=Q2155935
| Eigenschap | Claims |
|---|---|
| P17 | Brakke grond.jpg |
| P143 | 45 |
| P131 | 43-49 |
| P143 | http://www.brakkegrond.nl/ |
| P625 | 130852 |
| P18 | 1012 KD |
| P585 | De Brakke Grond (Amsterdam) |
| P31 | 0363100012168529 |
| P31 | 127643416 |
| P276 | a/5bbe4f22-2cde-4235-98bd-59f4552accc0 |
| P669 | Vlaams-Cultuurhuis-De-Brakke-Grond |
| P670 | brakkegrond |
| P670 | brakkegrond |
| P669 | a411d47d-5e4c-412c-9d51-794e43ded86c |
| P856 | org-007558 |
| P407 | http://data.advn.be/id |
| P84 | Q184047 |
| P3820 | https://theaterencyclopedie.nl/wiki/index.php?curid=123233 |
| P281 | https://theaterencyclopedie.nl/wiki/VSCD |
| P101 | |
| P6375 | |
| P373 | |
| P5208 | |
| P214 | |
| P8974 | |
| P3417 | |
| P2003 | |
| P2013 | |
| P1004 | |
| P248 | |
| P813 | |
| P12046 | |
| P854 | |
| P12674 | |
| P1619 | |
| P854 | |
| P2789 | |
| P463 | |
| P585 | |
| P854 |
NB: De matching tussen Property en Value is nog niet correct in bovenstaand overzicht!
https://www.wikidata.org/w/api.php?action=query&prop=wbgetclaims&id=Q2155935
Bovenstaande geeft errors:
- wbgetclaims is niet goed
- id is niet goed
https://www.wikidata.org/w/api.php?action=query&prop=wbgetentities&id=Q2155935