Permalink
Browse files

Normalized country related properties and fixed some mofo bugs

  • Loading branch information...
1 parent 0d1e00f commit 82735234186dd6f8d41a4056cd6fe08c947ccd4f @csarven committed Mar 15, 2012
Showing with 70 additions and 76 deletions.
  1. +29 −14 scripts/xsl/common.xsl
  2. +2 −8 scripts/xsl/finances-meta.xsl
  3. +39 −54 scripts/xsl/financesObservations.xsl
View
@@ -5,15 +5,9 @@
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dcterms="http://purl.org/dc/terms/"
- xmlns:wbldfn="http://worldbank.270a.info/xpath-function/"
- xmlns:func="http://exslt.org/functions"
- xmlns:is-date="http://www.intelligentstreaming.com/xsl/date-time"
- extension-element-prefixes="func"
- exclude-result-prefixes="func is-date"
- >
+ xmlns:wbldfn="http://worldbank.270a.info/xpath-function/">
<xsl:output encoding="utf-8" indent="yes" method="xml" omit-xml-declaration="no"/>
@@ -25,9 +19,7 @@
<xsl:function name="wbldfn:prepend-dataset">
<xsl:param name="string"/>
- <xsl:if test="$string = 'approval-quarter'
- or $string = 'calendar-year'
- or $string = 'financial-product'
+ <xsl:if test="$string = 'financial-product'
or $string = 'line-item'
or $string = 'organization'
or $string = 'source'
@@ -56,7 +48,7 @@ Ignoring mjsector[1-5].name for now. When there is classification/major-section
Ignoring sector[1-5].
..
-XXX: Review every single term here. Mostly projects-and-operations related. Only uuid and partially the project-name is from finances
+XXX: Review every single term here. Mostly projects-and-operations related. Only uuid, country-name, donor-name and partially the project-name is from finances.
-->
<xsl:if test="$string != ''
and $string != 'board-approval-month'
@@ -68,7 +60,9 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
and $string != 'countryshortname-and-mdk'
and $string != 'countryshortname-and-mdk-exact'
and $string != 'docty'
+ and $string != 'donor-name'
and $string != 'location'
+ and $string != 'beneficiary-name'
and $string != 'isrr-doc'
and $string != 'majorsector-percent'
and $string != 'mjsector'
@@ -118,6 +112,9 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
<xsl:when test="$string = 'bb-mlns-of-usd'">
<xsl:text>bb-us-millions</xsl:text>
</xsl:when>
+ <xsl:when test="$string = 'beneficiary-code'">
+ <xsl:text>beneficiary</xsl:text>
+ </xsl:when>
<xsl:when test="$string = 'betf-mlns-of-usd'">
<xsl:text>betf-us-millions</xsl:text>
</xsl:when>
@@ -145,12 +142,21 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
<xsl:when test="$string = 'credit-status'">
<xsl:text>loan-status</xsl:text>
</xsl:when>
+ <xsl:when test="$string = 'country-beneficiary'">
+ <xsl:text>beneficiary</xsl:text>
+ </xsl:when>
+ <xsl:when test="$string = 'country-code'">
+ <xsl:text>country</xsl:text>
+ </xsl:when>
<xsl:when test="$string = 'development-grant-expenses'">
<xsl:text>development-grant-expenses-us-millions</xsl:text>
</xsl:when>
<xsl:when test="$string = 'disbursements-usd'">
<xsl:text>disbursements-us-billions</xsl:text>
</xsl:when>
+ <xsl:when test="$string = 'donor-code'">
+ <xsl:text>donor</xsl:text>
+ </xsl:when>
<xsl:when test="$string = 'envassesmentcategorycode'">
<xsl:text>environmental-assessment-category-code</xsl:text>
</xsl:when>
@@ -166,6 +172,9 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
<xsl:when test="$string = 'gross-disbursements-total'">
<xsl:text>gross-disbursements-total-us-millions</xsl:text>
</xsl:when>
+ <xsl:when test="$string = 'guarantor-country-code'">
+ <xsl:text>guarantor</xsl:text>
+ </xsl:when>
<xsl:when test="$string = 'ibrdcommamt'">
<xsl:text>ibrd-commitment-amount</xsl:text>
</xsl:when>
@@ -193,8 +202,10 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
<xsl:when test="$string = 'loans-outstanding'">
<xsl:text>loans-outstanding-us-millions</xsl:text>
</xsl:when>
- <xsl:when test="$string = 'mjsectorcode'
- ">
+ <xsl:when test="$string = 'member-country'">
+ <xsl:text>member</xsl:text>
+ </xsl:when>
+ <xsl:when test="$string = 'mjsectorcode'">
<xsl:text>major-sector</xsl:text>
</xsl:when>
<xsl:when test="$string = 'net-disbursements'">
@@ -414,6 +425,11 @@ XXX: Review every single term here. Mostly projects-and-operations related. Only
<xsl:non-matching-substring>
<!--
+ xmlns:func="http://exslt.org/functions"
+ xmlns:is-date="http://www.intelligentstreaming.com/xsl/date-time"
+ extension-element-prefixes="func"
+ exclude-result-prefixes="func is-date"
+
<xsl:analyze-string select="$date" regex="([0-9]+)">
<xsl:matching-substring>
@@ -430,7 +446,6 @@ XXX: My brain stopped here. I can't be bothered with this POS. I need to sleep.
<xsl:value-of select="$date"/>
</xsl:non-matching-substring>
</xsl:analyze-string>
-
-->
<xsl:value-of select="$date"/>
@@ -84,8 +84,7 @@
or $data_element = 'agreement-signing-date'
or $data_element = 'approval-quarter'
or $data_element = 'as-of-date'
- or $data_element = 'beneficiary-code'
- or $data_element = 'beneficiary-name'
+ or $data_element = 'beneficiary'
or $data_element = 'board-approval-date'
or $data_element = 'borrower'
or $data_element = 'calendar-year'
@@ -94,13 +93,10 @@
or $data_element = 'contribution-type'
or $data_element = 'counterparty-rating'
or $data_element = 'country'
- or $data_element = 'country-code'
- or $data_element = 'country-beneficiary'
or $data_element = 'credit-status'
or $data_element = 'currency-of-commitment'
+ or $data_element = 'donor'
or $data_element = 'donor-agency'
- or $data_element = 'donor-code'
- or $data_element = 'donor-name'
or $data_element = 'effective-date-most-recent'
or $data_element = 'end-of-period'
or $data_element = 'financial-product'
@@ -115,15 +111,13 @@
or $data_element = 'grant-fund-number'
or $data_element = 'grant-name'
or $data_element = 'guarantor'
- or $data_element = 'guarantor-country-code'
or $data_element = 'last-disbursement-date'
or $data_element = 'last-repayment-date'
or $data_element = 'line-item'
or $data_element = 'loan-number'
or $data_element = 'loan-status'
or $data_element = 'loan-type'
or $data_element = 'member'
- or $data_element = 'member-country'
or $data_element = 'membership'
or $data_element = 'notes'
or $data_element = 'organization'
@@ -134,69 +134,54 @@
-->
<!-- These match up with ISO codes -->
- <xsl:when test="$nodeName = 'beneficiary-code'
- or $nodeName = 'country-code'
- or $nodeName = 'donor-code'
- or $nodeName = 'guarantor-country-code'">
+ <xsl:when test="$nodeName = 'beneficiary'
+ or $nodeName = 'country'
+ or $nodeName = 'donor'
+ or $nodeName = 'guarantor'
+ or $nodeName = 'member'
+ ">
+ <xsl:variable name="countryString" select="normalize-space(./text())"/>
+
<xsl:choose>
- <xsl:when test="./text() = ''">
+ <xsl:when test="$countryString = ''">
<xsl:element name="property:{$datasetName}{$nodeName}"/>
</xsl:when>
<xsl:otherwise>
- <xsl:element name="property:{$datasetName}{$nodeName}">
- <xsl:attribute name="rdf:resource">
- <xsl:value-of select="$classification"/><xsl:text>country/</xsl:text><xsl:value-of select="normalize-space(./text())"/>
- </xsl:attribute>
- </xsl:element>
+ <xsl:choose>
+ <xsl:when test="string-length($countryString) = 2">
+ <xsl:element name="property:{$datasetName}{$nodeName}">
+ <xsl:attribute name="rdf:resource">
+ <xsl:value-of select="$classification"/><xsl:text>country/</xsl:text><xsl:value-of select="$countryString"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:choose>
+ <!--
+ TODO: Some of the countries don't match e.g., "Yemen, Rep." in countries.xml and "Yemen, People's Democratic Republic of" or "Yemen, Republic of" in ax5s-vav5.xml.
+ -->
+ <xsl:when test="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]">
+ <xsl:element name="property:{$datasetName}{$nodeName}">
+ <xsl:attribute name="rdf:resource">
+ <xsl:value-of select="$classification"/><xsl:text>country/</xsl:text><xsl:value-of select="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]/wb:iso2Code/normalize-space(text())"/>
+ </xsl:attribute>
+ </xsl:element>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:element name="property:{$datasetName}{$nodeName}">
+ <xsl:value-of select="$countryString"/>
+ </xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
- <!--
- TODO: Some of the countries don't match e.g., "Yemen, Rep." in countries.xml and "Yemen, People's Democratic Republic of" or "Yemen, Republic of" in ax5s-vav5.xml.
- XXX: Currently using sdmx-dimension:refArea "Yemen, Republic of". Could use property:country_beneficiary "Yemen, Republic of". Not sure about it right now.
- -->
- <xsl:when test="$nodeName = 'country'">
- <xsl:variable name="countryString" select="./text()"/>
-
- <xsl:element name="property:{$datasetName}{$nodeName}">
- <xsl:choose>
- <xsl:when test="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]">
- <xsl:attribute name="rdf:resource">
- <xsl:value-of select="$classification"/><xsl:text>country/</xsl:text><xsl:value-of select="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]/wb:iso2Code/normalize-space(text())"/>
- </xsl:attribute>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:value-of select="./text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:when>
-
- <xsl:when test="$nodeName = 'country-beneficiary'
- or $nodeName = 'donor-name'
- or $nodeName = 'guarantor'
- or $nodeName = 'member'
- or $nodeName = 'member-country'">
- <xsl:variable name="countryString" select="normalize-space(./text())"/>
-
- <xsl:element name="property:{$datasetName}{$nodeName}">
- <xsl:choose>
- <xsl:when test="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]">
- <xsl:attribute name="rdf:resource">
- <xsl:value-of select="$classification"/><xsl:text>country/</xsl:text><xsl:value-of select="document($pathToCountries)/wb:countries/wb:country[wb:name/text() = $countryString]/wb:iso2Code/normalize-space(text())"/>
- </xsl:attribute>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:value-of select="./text()"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
- </xsl:when>
-
<xsl:when test="$nodeName = 'region'">
<xsl:variable name="regionString" select="./text()"/>

0 comments on commit 8273523

Please sign in to comment.