Gebruiksaanwijzing extensie External Data: verschil tussen versies

Uit MediaWikiGids
Ga naar: navigatie, zoeken
k
k
Regel 176: Regel 176:
 
{{#get_web_data: url=https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=Q2155935&format=json
 
{{#get_web_data: url=https://www.wikidata.org/w/api.php?action=wbgetclaims&entity=Q2155935&format=json
 
|format=JSON
 
|format=JSON
|data= wikiclaims = value
+
|data= eigenschap = property, wikiclaims = value
 
}}
 
}}
  
 
{| class="wikitable"
 
{| class="wikitable"
 +
! Eigenschap
 
! Claims {{#for_external_table:<nowiki/>
 
! Claims {{#for_external_table:<nowiki/>
 
{{!}}-
 
{{!}}-
 +
{{!}} {{{eigenschap}}}
 
{{!}} {{{wikiclaims}}}
 
{{!}} {{{wikiclaims}}}
 
}}
 
}}
 
|}
 
|}

Versie van 28 feb 2018 om 01:04

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

Voorbeeld labels

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: '

Voorbeeld Aliases

Aliases
Vlaams Cultuurhuis
Brakke Grond
Poortje 'De Brakke Grond'
rijksmonumentnummer 6157

Voorbeeld "Claims"

Eigenschap Claims
P17 Brakke grond.jpg
P143 Brakke grond gate.jpg
P131 45
P143 http://www.brakkegrond.nl/
P625 130852
P143 1012 KD
P625 1017 SG
P18 1012GL
P18 https://cultureelerfgoed.nl/monumenten/6157
P31 6157
P31 De Brakke Grond (Amsterdam)
P31 0363100012179547
P276 127643416
P669 viaf-127643416
P670 127643416
P856 a/5bbe4f22-2cde-4235-98bd-59f4552accc0
P407 Vlaams-Cultuurhuis-De-Brakke-Grond
P84 brakkegrond
P3820 brakkegrond
P281 a411d47d-5e4c-412c-9d51-794e43ded86c
P281 org-007558
P281 http://data.advn.be/id
P248
P854
P407
P813
P101
P6375
P6375
P359
P373
P1435
P580
P248
P5208
P214
P7859
P214
P8974
P3417
P2003
P2013
P1004
P248
P813
P12046
P854