Skip to content

Instantly share code, notes, and snippets.

@vpinna80
Created April 11, 2018 12:23
Show Gist options
  • Save vpinna80/79d2afb2033d6f79e169ae8065cb77d2 to your computer and use it in GitHub Desktop.
Save vpinna80/79d2afb2033d6f79e169ae8065cb77d2 to your computer and use it in GitHub Desktop.
Extract series metadata from SDMX 2.1 GenericData xml file.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:o="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message"
xmlns:common="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/common" xmlns:compact="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/compact"
xmlns:cross="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/cross" xmlns:generic="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/generic"
xmlns:query="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/query" xmlns:utility="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/utility"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.SDMX.org/resources/SDMXML/schemas/v2_0/message SDMXMessage.xsd">
<xsl:output method="text" encoding="UTF-8" omit-xml-declaration="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="o:Header" />
<xsl:template match="generic:KeyFamilyRef" />
<xsl:template match="generic:Series">
<xsl:for-each select="generic:SeriesKey/generic:Value">
<xsl:value-of select="@concept" />=<xsl:value-of select="@value" />
<xsl:if test="position() &lt; last()">,</xsl:if>
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment