Entity-Relationship Model (ERM) — Wikibase Mapping

This directory contains the artefacts for mapping the IPCC AR6 XML/DTD data model to the local Wikibase instance, generating both a flat CSV property table and a Mermaid entity-relationship diagram.


Directory contents

File Role
erm-wikibase-mapping.xml Source of truth — XML that maps every DTD entity and field to a real Wikibase Property (PID) or Item (QID)
erm-to-csv.xslt XSLT 1.0 stylesheet: transforms mapping XML → flat CSV
erm-to-mermaid.xslt XSLT 1.0 stylesheet: transforms mapping XML → Mermaid erDiagram
generate-erm.ps1 PowerShell runner — executes both transforms in one step
erm-mapping.csv Generated output — entity/property table (73 rows)
er-diagram-wikibase.mmd Generated output — Mermaid ER diagram with real QIDs and PIDs

Workflow

DTD files (parent data-xml-dtd/)
        │
        ▼
[Manual step] SPARQL query against local Wikibase
  http://localhost:9999/bigdata/namespace/wdq/sparql
  → retrieve all Properties (P1–P33) and class Items (Q-IDs)
        │
        ▼
erm-wikibase-mapping.xml  ◄── edit this file to update the mapping
        │
        ├──[erm-to-csv.xslt]──────► erm-mapping.csv
        │
        └──[erm-to-mermaid.xslt]──► er-diagram-wikibase.mmd

Step 1 — Query Wikibase for PIDs and QIDs

The mapping XML was populated by querying the local Wikibase SPARQL endpoint. Example SPARQL (uses explicit prefixes required by this Wikibase instance):

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?prop ?num ?label WHERE {
  ?prop a wikibase:Property .
  ?prop wikibase:propertyType ?type .
  BIND(REPLACE(STR(?prop), ".*/", "") AS ?num)
  OPTIONAL { ?prop rdfs:label ?label FILTER(LANG(?label) = "en") }
}
ORDER BY xsd:integer(SUBSTR(?num, 2))

Step 2 — Maintain erm-wikibase-mapping.xml

This is the only file you need to edit manually. Structure:

<erm-mapping>
  <dtd name="corpus-ar6">
    <entity name="WORK" qid="Q2" label="Work">
      <field name="instance_of" pid="P1" label="Instance of"
             datatype="WikibaseItem" notes="P1=Q2"/>
      ...
    </entity>
    <relationship from="REPORT_SERIES" to="REPORT"
                  cardinality="||--o{" label="P4 contains"/>
  </dtd>
  ...
</erm-mapping>

Five DTD sections in hierarchy order:

  1. corpus-ar6 — top-level corpus (Work Q2, Report Series Q3, Report Q4, Text Division Q5, Chapter Q6)
  2. authors-ar6 — IPCC AR6 author records (Author Q3998)
  3. bibliographic-ar6 — DOI bibliographic enrichment (adds P29–P33 to Report and Chapter)
  4. glossary-ar6 — glossary terms (Category Q1)
  5. acronyms-ar6 — acronym list (Acronym Q2087)

Step 3 — Regenerate outputs

Run from PowerShell inside this directory (or any working directory — the script uses $PSScriptRoot):

.\generate-erm.ps1

Requires: Windows PowerShell 5.1+ or PowerShell 7+, .NET System.Xml.Xsl.XslCompiledTransform (built-in on Windows).

Outputs written as UTF-8 without BOM (required by the Mermaid parser).


Wikibase property reference (P1–P33)

PID Label Type
P1 Instance of WikibaseItem
P2 Instances WikibaseItem
P3 Part of WikibaseItem
P4 Parts WikibaseItem
P5 Wiki Url
P6 Source Url
P7 PDF Url
P8 Date String
P9 OPENALEX String
P10 DOI String
P11 LICENSE String
P12 Has TAG WikibaseItem
P13 Definition Monolingualtext
P17 date accessed Time
P18 date accessed Time
P19 source version String
P20 ClimateKG Author ID String
P21 last name String
P22 first name String
P23 gender String
P24 citizenship String
P25 country of residence String
P26 affiliation String
P27 contributed to chapter WikibaseItem
P28 role String
P29 Publisher DOI String
P30 ISBN Electronic DOI String
P31 ISBN Print DOI String
P32 Licence URL DOI Url
P33 Abstract DOI String

Wikibase class items (QIDs)

QID Label Also Known As Example item
Q1 Category (Glossary Terms) Q1005
Q2 Work Q7
Q3 Report Series Monographic Series Q7
Q4 Report Book; Monograph; Volume Q10
Q5 Text Division Division Q110
Q6 Chapter Q154
Q2087 Acronym Q3880
Q3998 Author Q4047

Previewing the diagram

The diagram can also be viewed online at mermaid.live.

This diagram maps the IPCC AR6 XML/DTD entities to their corresponding Wikibase properties (PIDs) and class items (QIDs) on the local ClimateKG Wikibase instance.

Source file: er-diagram-wikibase.mmd — regenerate by running generate-erm.ps1 whenever erm-wikibase-mapping.xml changes.

erDiagram

    WORK {
        WikibaseItem instance_of "P1 Instance of: P1=Q2"
    }
    REPORT_SERIES {
        WikibaseItem instance_of "P1 Instance of: P1=Q3"
        String title "rdfs:label item label"
        String description "rdfs:description item description"
        WikibaseItem part_of "P3 Part of: parent Work"
        WikibaseItem parts "P4 Parts: child Series or Books"
    }
    REPORT {
        WikibaseItem instance_of "P1 Instance of: P1=Q4"
        String title "rdfs:label item label"
        String doi "P10 DOI"
        String isbn_elec "P30 ISBN Electronic (DOI)"
        String isbn_print "P31 ISBN Print (DOI)"
        String license "P11 LICENSE"
        WikibaseItem tags "P12 Has TAG"
        String date "P8 Date"
        Url pdf "P7 PDF"
        String openalex "P9 OPENALEX"
        WikibaseItem part_of "P3 Part of: parent Report Series"
        WikibaseItem parts "P4 Parts: child Books and Chapters"
    }
    TEXT_DIVISION {
        WikibaseItem instance_of "P1 Instance of: P1=Q5"
        String title "rdfs:label item label"
        String doi "P10 DOI"
        String isbn_elec "P30 ISBN Electronic (DOI)"
        String isbn_print "P31 ISBN Print (DOI)"
        String license "P11 LICENSE"
        WikibaseItem tags "P12 Has TAG"
        String date "P8 Date"
        Url pdf "P7 PDF"
        String openalex "P9 OPENALEX"
        WikibaseItem part_of "P3 Part of: parent Series"
        WikibaseItem parts "P4 Parts: child Chapters"
    }
    CHAPTER {
        WikibaseItem instance_of "P1 Instance of: P1=Q6"
        String title "rdfs:label item label"
        String doi "P10 DOI"
        String openalex "P9 OPENALEX"
        Url wiki "P5 Wiki"
        Url source "P6 Source"
        Url pdf "P7 PDF"
        WikibaseItem tags "P12 Has TAG"
        WikibaseItem part_of "P3 Part of: parent Book"
    }

    AUTHOR {
        WikibaseItem instance_of "P1 Instance of: P1=Q3998"
        String climatkg_author_id "P20 ClimateKG Author ID: e.g. AU0001"
        String last_name "P21 last name"
        String first_name "P22 first name"
        String gender "P23 gender: M or F"
        String citizenship "P24 citizenship"
        String country_of_residence "P25 country of residence"
        String affiliation "P26 affiliation"
        WikibaseItem contributed_to "P27 contributed to chapter: FK to Q6 Chapter"
    }

    GLOSSARY_TERM {
        WikibaseItem instance_of "P1 Instance of: P1=Q1 Category"
        String name "rdfs:label item label"
        String also_known_as "skos:altLabel item alias"
        Monolingualtext definition "P13 Definition"
        WikibaseItem part_of_series "P3 Part of: FK to Q4 Series via series_ref"
    }

    ACRONYM {
        WikibaseItem instance_of "P1 Instance of: P1=Q2087"
        String code "rdfs:label acronym code as item label"
        Monolingualtext description "P13 Definition: multiple; source as qualifier"
        WikibaseItem report "P3 Part of: FK to Q4 Series (report)"
    }

    WORK ||--|{ REPORT_SERIES : "contains"
    REPORT_SERIES ||--|{ REPORT : "contains"
    REPORT ||--|{ TEXT_DIVISION : "contains"
    TEXT_DIVISION ||--|{ CHAPTER : "contains"
    AUTHOR ||--|{ CHAPTER : "contributes to"
    REPORT ||--|{ GLOSSARY_TERM : "has"
    REPORT ||--|{ ACRONYM : "has"