Gebruiksaanwijzing extensie External Data

Uit MediaWikiGids
Versie door Bmulckhu (Overleg | bijdragen) op 23 feb 2018 om 19:22 (Testccase 2 - Gebruik External Data om gegevens uit Wikidata via API op te halen: correctie)

Ga naar: navigatie, zoeken

Je vindt hier de officiële gebruiksaanwijzing van de Extension:External_Data.

De extensie werkt in twee stappen:

  1. Laad de gegevens uit externe bron
  2. 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: }} 

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:

  1. Het attribuut / label (attribute, tag) priref is weggelaten, omdat het dubbel voorkomt. Het gebruik Xpath kan hiervoor een oplossing bieden.
  2. 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).


Creatie Modificatie Geselec
teerd
Administra
tienaam
Maker Categorie Object nummer Reproductie
referentie
Titel Taal

2007-02-07T13:40:36 2016-08-25T08:33:57 False PDP Ghirlandaio, Domenico (Domenico Bigordi) painting M.54 M.54.jpg The Nativity nl-NL
2007-02-07T13:40:36 2016-08-25T08:33:49 False PDP Bert Degenhart Drenth painting 99 99.jpg The Transfiguration nl-NL
2007-02-07T13:40:36 2016-08-25T08:34:09 False PDP Batoni, Pompeo Girolamo painting PD.4-1950 PD.4-1950.jpg The 7th Earl of Northampton nl-NL
2007-02-07T13:40:36 2016-08-25T08:34:09 False PDP Constable, John painting PD.207-1948 PD.207-1948.jpg Hampstead Heath nl-NL
2007-02-07T13:40:36 2016-08-25T08:34:09 False PDP Rosa, Salvator painting PD.53-1958 PD.53-1958.jpg L'Umana Fragilit nl-NL
2007-02-07T13:40:36 2016-08-25T08:34:09 False PDP Elmore, Alfred painting PD.108-1975 PD.108-1975.jpg à nl-NL
2007-02-07T13:40:36 2016-08-25T08:33:57 False PDP Sellaio, Jacopo del painting M.75 M.75.jpg On the Brink (1865) nl-NL
2007-02-07T13:40:36 2017-01-27T15:46:11 False PDP Rossetti, Dante Gabriel drawing 2151 2151.jpg The Story of Cupid and Psyche nl-NL
2007-02-07T13:40:36 2016-08-25T08:33:41 False PDP Turner, Joseph Mallord William drawing 2476 2476.jpg Mary Magdalene at the Door of Simon the Pharisee nl-NL
2007-02-07T13:40:36 2017-06-20T21:51:58 False PDP Sickert, Walter Richard painting 2458 2458.jpg The field of Waterloo nl-NL
The Old Bedford nl-NL
The boy I love is up in the gallery nl-NL
Cupid in the gallery

Testccase 2 - Gebruik External Data om gegevens uit Wikidata via API op te halen

Gebruik External data om het "label" (naam van de pagina op Wikipedia ?) op te vragen van het item "Q42" in Wikidata.org:

{{#get_web_data: url=https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42&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=Q42&props=labels&languages=nl
&format=json. Resultaat: '