DEV Community

anthony b
anthony b

Posted on

XML, making everything just a little bit harder.

So here's a fun exercise in XML, standards, and data catalogs.

I'm working on ingesting a bunch of records from a variety of data catalogs, of a variety of types. One I'm looking at now uses OAI-PMH. Fortunately there's a nice little Python library called Sickle that abstracts most of the pain away. Until you're dealing with non Dublin Core datasets.

Sickle does allow you to plug in a parser for other types (oh hi XPath, I haven't missed you at all)

The dataset I'm using uses the ANZLIC profile for OAI-PMH (fun side note, the official repo for the info had a broken link to the standard, because bitrot even comes for ISO committees.) It's catchier name is "AS/NZS ISO 19115.1:2015 Metadata".

So I need to write a custom parser for this.

Then I hit this, when looking for keywords in a data record.

          <gco:CharacterString>Australian and New Zealand Standard Research Classification</gco:CharacterString>
              <gmd:CI_DateTypeCode codeList="" codeListValue="creation">creation</gmd:CI_DateTypeCode>
Enter fullscreen mode Exit fullscreen mode

What on earth is this nonsense? So we can ignore the date code bit (fun sidenote, the domain no longer exists, lucky it's not important - I reckon I can interpret "2008" as a date without an xsd file)

So obviously 040104 is a reference to something.

A bunch of googling and staring at the wall finally led me to the Australian Bureau of Statistics, in particular to standard 1297.0 Australian and New Zealand Standard Research Classification (2008) is the current version.

From there, you can go to the downloads tab, and find the table where it maps the 2008 codes to 2020 codes. In a 1.5Mb Excel file. So I exported out the relevant bits of the 2008 codes, throw them in a small sqlite db, and end up with 040104,Climate Change Processes

So all that XML up above? It could have just been

<keyword>Climate Change Processes</keyword>

But nooooo.

Top comments (0)