Example #1
0
    def test_pretty_print(self):
        """Test pretty-printing"""

        xml = render_template(get_abspath('../sample.mcf'), 'iso19139')
        xml2 = pretty_print(xml)

        self.assertIsInstance(xml2, text_type, 'Expected unicode string')
        self.assertEqual(xml2[-1], '>', 'Expected closing bracket')
        self.assertTrue(xml2.startswith('<?xml'), 'Expected XML declaration')
Example #2
0
    def test_pretty_print(self):
        """Test pretty-printing"""

        xml = render_template(get_abspath('../sample.mcf'), 'iso19139')
        xml2 = pretty_print(xml)

        self.assertIsInstance(xml2, text_type, 'Expected unicode string')
        self.assertEqual(xml2[-1], '>', 'Expected closing bracket')
        self.assertTrue(xml2.startswith('<?xml'), 'Expected XML declaration')
Example #3
0
def process_args(mcf, schema, schema_local, output):
    if mcf is None or (schema is None and schema_local is None):
        raise click.UsageError('Missing arguments')
    else:
        content = render_template(mcf, schema=schema,
                                  schema_local=schema_local)
        if output is None:
            click.echo_via_pager(content)
        else:
            output.write(content)
Example #4
0
def process_args(mcf, schema, schema_local, output):
    if mcf is None or (schema is None and schema_local is None):
        raise click.UsageError('Missing arguments')
    else:
        content = render_template(mcf,
                                  schema=schema,
                                  schema_local=schema_local)
        if output is None:
            click.echo_via_pager(content)
        else:
            output.write(content)
Example #5
0
    def test_render_template(self):
        """test template rendering"""

        test_mcf_paths = ['../sample.mcf', 'unilingual.mcf']

        for mcf_path in test_mcf_paths:
            xml = render_template(get_abspath(mcf_path), 'iso19139')
            self.assertIsInstance(xml, text_type, 'Expected unicode string')

            # no schema provided
            with self.assertRaises(RuntimeError):
                render_template(get_abspath(mcf_path))

            # bad schema provided
            with self.assertRaises(RuntimeError):
                xml = render_template(get_abspath(mcf_path), 'bad_schema')

            # bad schema_local provided
            with self.assertRaises(RuntimeError):
                xml = render_template(get_abspath(mcf_path),
                                      schema_local='/bad_schema/path')

            # good schema_local provided
            xml = render_template(get_abspath(mcf_path),
                                  schema_local=get_abspath('sample_schema'))
Example #6
0
    def test_render_template(self):
        """test template rendering"""

        test_mcf_paths = [
            '../sample.mcf', 'unilingual.mcf',
            'nil-identification-language.mcf'
        ]

        for mcf_path in test_mcf_paths:
            xml = render_template(get_abspath(mcf_path), 'iso19139')
            self.assertIsInstance(xml, text_type, 'Expected unicode string')

            # no schema provided
            with self.assertRaises(RuntimeError):
                render_template(get_abspath(mcf_path))

            # bad schema provided
            with self.assertRaises(RuntimeError):
                xml = render_template(get_abspath(mcf_path), 'bad_schema')

            # bad schema_local provided
            with self.assertRaises(RuntimeError):
                xml = render_template(get_abspath(mcf_path),
                                      schema_local='/bad_schema/path')

            # good schema_local provided
            xml = render_template(get_abspath(mcf_path),
                                  schema_local=get_abspath('sample_schema'))
Example #7
0
    def test_render_template(self):
        """test template rendering"""

        xml = render_template(get_abspath('../sample.mcf'), 'iso19139')
        self.assertIsInstance(xml, text_type, 'Expected unicode string')

        # no schema provided
        with self.assertRaises(RuntimeError):
            render_template(get_abspath('../sample.mcf'))

        # bad schema provided
        with self.assertRaises(RuntimeError):
            xml = render_template(get_abspath('../sample.mcf'), 'bad_schema')

        # bad schema_local provided
        with self.assertRaises(RuntimeError):
            xml = render_template(get_abspath('../sample.mcf'),
                                  schema_local='/bad_schema/path')

        # good schema_local provided
        xml = render_template(get_abspath('../sample.mcf'),
                              schema_local=get_abspath('sample_schema'))
Example #8
0
    def test_render_template(self):
        """test template rendering"""

        xml = render_template(get_abspath('../sample.mcf'), 'iso19139')
        self.assertIsInstance(xml, unicode, 'Expected unicode string')

        # no schema provided
        with self.assertRaises(RuntimeError):
            render_template(get_abspath('../sample.mcf'))

        # bad schema provided
        with self.assertRaises(RuntimeError):
            xml = render_template(get_abspath('../sample.mcf'), 'bad_schema')

        # bad schema_local provided
        with self.assertRaises(RuntimeError):
            xml = render_template(get_abspath('../sample.mcf'),
                                  schema_local='/bad_schema/path')

        # good schema_local provided
        xml = render_template(get_abspath('../sample.mcf'),
                              schema_local=get_abspath('sample_schema'))
Example #9
0
def _control_string_to_geographic_metadata(metadata_control):
    """
    returns ISO Geographic MetaData XML representation of control string

    Keyword Parameters:
    metadata_control  -- String, representing contents of a pygeometa
      'metadata control' file (ConfigParser-style formatting)

    >>> from pprint import pprint
    >>> sample = '''[metadata]
    ... identifier=3f342f64-9348-11df-ba6a-0014c2c00eab
    ... language=en
    ... language_alternate=fr
    ... charset=utf8
    ... parentidentifier=someparentid
    ... hierarchylevel=dataset
    ... datestamp=2014-11-11
    ... dataseturi=http://some/minted/uri
    ... 
    ... [spatial]
    ... datatype=vector
    ... geomtype=point
    ... crs=4326
    ... bbox=-141,42,-52,84
    ... 
    ... [identification]
    ... language=eng; CAN
    ... charset=utf8
    ... title_en=title in English
    ... title_fr=title in French
    ... abstract_en=abstract in English
    ... abstract_fr=abstract in French
    ... keywords_en=kw1 in English,kw2 in English,kw3 in English
    ... keywords_fr=kw1 in French,kw2 in French,kw3 in French
    ... keywords_type=theme
    ... keywords_gc_cst_en=kw1,kw2
    ... keywords_gc_cst_fr=kw1,kw2
    ... topiccategory=climatologyMeteorologyAtmosphere
    ... publication_date=2000-09-01T00:00:00Z
    ... fees=None
    ... accessconstraints=otherRestrictions
    ... rights_en=Copyright (c) 2010 Her Majesty the Queen in Right of Canada
    ... rights_fr=Copyright (c) 2010 Her Majesty the Queen in Right of Canada
    ... url=http://geogratis.ca/geogratis/en/product/search.do?id=08DB5E85-7405-FE3A-2860-CC3663245625
    ... temporal_begin=1950-07-31
    ... temporal_end=now
    ... status=onGoing
    ... maintenancefrequency=continual
    ... 
    ... [contact:main]
    ... organization=Environment Canada
    ... url=http://www.ec.gc.ca/
    ... individualname=Tom Kralidis
    ... positionname=Senior Systems Scientist
    ... phone=+01-123-456-7890
    ... fax=+01-123-456-7890
    ... address=4905 Dufferin Street
    ... city=Toronto
    ... administrativearea=Ontario
    ... postalcode=M3H 5T4
    ... country=Canada
    ... [email protected]
    ... hoursofservice=0700h - 1500h EST
    ... contactinstructions=email
    ... 
    ... [contact:distribution]
    ... #ref=contact:main
    ... organization=Environment Canada
    ... url=http://www.ec.gc.ca/
    ... individualname=Tom Kralidis
    ... positionname=Senior Systems Scientist
    ... phone=+01-123-456-7890
    ... fax=+01-123-456-7890
    ... address=4905 Dufferin Street
    ... city=Toronto
    ... administrativearea=Ontario
    ... postalcode=M3H 5T4
    ... country=Canada
    ... [email protected]
    ... hoursofservice=0700h - 1500h EST
    ... contactinstructions=email
    ... 
    ... [distribution:waf]
    ... url=http://dd.meteo.gc.ca
    ... type=WWW:LINK
    ... name=my waf
    ... description_en=description in English
    ... description_fr=description in French
    ... function=download
    ... 
    ... [distribution:wms]
    ... url=http://dd.meteo.gc.ca
    ... type=OGC:WMS
    ... name_en=roads
    ... name_fr=routes
    ... description_en=description in English
    ... description_fr=description in French
    ... function=download'''
    >>> xml = _control_string_to_geographic_metadata(sample)
    >>> pprint(xml, width=78) # doctest: +ELLIPSIS
    ('<?xml version="1.0" ?>\\n'
     '<gmd:MD_Metadata xmlns:gco="http://www.isotc211.org/2005/gco" '
     'xmlns:gmd="http://www.isotc211.org/2005/gmd" '
     'xmlns:gml="http://www.opengis.net/gml/3.2" '
     'xmlns:gmx="http://www.isotc211.org/2005/gmx" '
     'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
     'xsi:schemaLocation="http://www.isotc211.org/2005/gmd '
     'http://www.isotc211.org/2005/gmd/gmd.xsd http://www.isotc211.org/2005/gmx '
     'http://www.isotc211.org/2005/gmx/gmx.xsd">\\n'
     '  <gmd:fileIdentifier>\\n'
     '    '
     '<gco:CharacterString>3f342f64-9348-11df-ba6a-0014c2c00eab</gco:CharacterString>\\n'
     '  </gmd:fileIdentifier>\\n'
     '  <gmd:language>\\n'
     '    <gmd:LanguageCode codeList="http://www.loc.gov/standards/iso639-2/" '
     'codeListValue="en" codeSpace="ISO 639-2">en</gmd:LanguageCode>\\n'
     '  </gmd:language>\\n'
     '  <gmd:characterSet>\\n'
     '    <gmd:MD_CharacterSetCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" '
     'codeListValue="utf8" '
     'codeSpace="ISOTC211/19115">utf8</gmd:MD_CharacterSetCode>\\n'
     '  </gmd:characterSet>\\n'
     '  <gmd:parentIdentifier>\\n'
     '    <gco:CharacterString>someparentid</gco:CharacterString>\\n'
     '  </gmd:parentIdentifier>\\n'
     '  <gmd:hierarchyLevel>\\n'
     '    <gmd:MD_ScopeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" '
     'codeListValue="dataset" '
     'codeSpace="ISOTC211/19115">dataset</gmd:MD_ScopeCode>\\n'
     '  </gmd:hierarchyLevel>\\n'
     '  <gmd:contact>\\n'
     '    <gmd:CI_ResponsibleParty>\\n'
     '      <gmd:individualName>\\n'
     '        <gco:CharacterString>Tom Kralidis</gco:CharacterString>\\n'
     '      </gmd:individualName>\\n'
     '      <gmd:organisationName>\\n'
     '        <gco:CharacterString>Environment Canada</gco:CharacterString>\\n'
     '      </gmd:organisationName>\\n'
     '      <gmd:positionName>\\n'
     '        <gco:CharacterString>Senior Systems '
     'Scientist</gco:CharacterString>\\n'
     '      </gmd:positionName>\\n'
     '      <gmd:contactInfo>\\n'
     '        <gmd:CI_Contact>\\n'
     '          <gmd:phone>\\n'
     '            <gmd:CI_Telephone>\\n'
     '              <gmd:voice>\\n'
     '                '
     '<gco:CharacterString>+01-123-456-7890</gco:CharacterString>\\n'
     '              </gmd:voice>\\n'
     '              <gmd:facsimile>\\n'
     '                '
     '<gco:CharacterString>+01-123-456-7890</gco:CharacterString>\\n'
     '              </gmd:facsimile>\\n'
     '            </gmd:CI_Telephone>\\n'
     '          </gmd:phone>\\n'
     '          <gmd:address>\\n'
     '            <gmd:CI_Address>\\n'
     '              <gmd:deliveryPoint>\\n'
     '                <gco:CharacterString>4905 Dufferin '
     'Street</gco:CharacterString>\\n'
     '              </gmd:deliveryPoint>\\n'
     '              <gmd:city>\\n'
     '                <gco:CharacterString>Toronto</gco:CharacterString>\\n'
     '              </gmd:city>\\n'
     '              <gmd:administrativeArea>\\n'
     '                <gco:CharacterString>Ontario</gco:CharacterString>\\n'
     '              </gmd:administrativeArea>\\n'
     '              <gmd:postalCode>\\n'
     '                <gco:CharacterString>M3H 5T4</gco:CharacterString>\\n'
     '              </gmd:postalCode>\\n'
     '              <gmd:country>\\n'
     '                <gco:CharacterString>Canada</gco:CharacterString>\\n'
     '              </gmd:country>\\n'
     '              <gmd:electronicMailAddress>\\n'
     '                <gco:CharacterString>[email protected]</gco:CharacterString>\\n'
     '              </gmd:electronicMailAddress>\\n'
     '            </gmd:CI_Address>\\n'
     '          </gmd:address>\\n'
     '          <gmd:onlineResource>\\n'
     '            <gmd:CI_OnlineResource>\\n'
     '              <gmd:linkage>\\n'
     '                <gmd:URL>http://www.ec.gc.ca/</gmd:URL>\\n'
     '              </gmd:linkage>\\n'
     '              <gmd:protocol>\\n'
     '                <gco:CharacterString>WWW:LINK</gco:CharacterString>\\n'
     '              </gmd:protocol>\\n'
     '            </gmd:CI_OnlineResource>\\n'
     '          </gmd:onlineResource>\\n'
     '          <gmd:hoursOfService>\\n'
     '            <gco:CharacterString>0700h - 1500h EST</gco:CharacterString>\\n'
     '          </gmd:hoursOfService>\\n'
     '          <gmd:contactInstructions>\\n'
     '            <gco:CharacterString>email</gco:CharacterString>\\n'
     '          </gmd:contactInstructions>\\n'
     '        </gmd:CI_Contact>\\n'
     '      </gmd:contactInfo>\\n'
     '      <gmd:role>\\n'
     '        <gmd:CI_RoleCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" '
     'codeListValue="pointOfContact" '
     'codeSpace="ISOTC211/19115">pointOfContact</gmd:CI_RoleCode>\\n'
     '      </gmd:role>\\n'
     '    </gmd:CI_ResponsibleParty>\\n'
     '  </gmd:contact>\\n'
     '  <gmd:dateStamp>\\n'
     '    <gco:Date>2014-11-11</gco:Date>\\n'
     '  </gmd:dateStamp>\\n'
     '  <gmd:metadataStandardName>\\n'
     '    <gco:CharacterString>ISO 19115:2003 - Geographic information - '
     'Metadata</gco:CharacterString>\\n'
     '  </gmd:metadataStandardName>\\n'
     '  <gmd:metadataStandardVersion>\\n'
     '    <gco:CharacterString>ISO 19115:2003</gco:CharacterString>\\n'
     '  </gmd:metadataStandardVersion>\\n'
     '  <gmd:dataSetURI>\\n'
     '    <gco:CharacterString>http://some/minted/uri</gco:CharacterString>\\n'
     '  </gmd:dataSetURI>\\n'
     '  <gmd:locale>\\n'
     '    <gmd:PT_Locale id="locale-fr">\\n'
     '      <gmd:languageCode>\\n'
     '        <gmd:LanguageCode '
     'codeList="http://www.loc.gov/standards/iso639-2/" codeListValue="fr" '
     'codeSpace="ISO 639-2">fr</gmd:LanguageCode>\\n'
     '      </gmd:languageCode>\\n'
     '      <gmd:characterEncoding>\\n'
     '        <gmd:MD_CharacterSetCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" '
     'codeListValue="utf8" '
     'codeSpace="ISOTC211/19115">utf8</gmd:MD_CharacterSetCode>\\n'
     '      </gmd:characterEncoding>\\n'
     '    </gmd:PT_Locale>\\n'
     '  </gmd:locale>\\n'
     '  <gmd:spatialRepresentationInfo>\\n'
     '    <gmd:MD_VectorSpatialRepresentation>\\n'
     '      <gmd:topologyLevel>\\n'
     '        <gmd:MD_TopologyLevelCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_TopologyLevelCode" '
     'codeListValue="geometryOnly" '
     'codeSpace="ISOTC211/19115">geometryOnly</gmd:MD_TopologyLevelCode>\\n'
     '      </gmd:topologyLevel>\\n'
     '      <gmd:geometricObjects>\\n'
     '        <gmd:MD_GeometricObjects>\\n'
     '          <gmd:geometricObjectType>\\n'
     '            <gmd:MD_GeometricObjectTypeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_GeometricObjectTypeCode" '
     'codeListValue="point" '
     'codeSpace="ISOTC211/19115">point</gmd:MD_GeometricObjectTypeCode>\\n'
     '          </gmd:geometricObjectType>\\n'
     '        </gmd:MD_GeometricObjects>\\n'
     '      </gmd:geometricObjects>\\n'
     '    </gmd:MD_VectorSpatialRepresentation>\\n'
     '  </gmd:spatialRepresentationInfo>\\n'
     '  <gmd:referenceSystemInfo>\\n'
     '    <gmd:MD_ReferenceSystem>\\n'
     '      <gmd:referenceSystemIdentifier>\\n'
     '        <gmd:RS_Identifier>\\n'
     '          <gmd:authority>\\n'
     '            <gmd:CI_Citation>\\n'
     '              <gmd:title>\\n'
     '                <gco:CharacterString>European Petroleum Survey Group '
     '(EPSG) Geodetic Parameter Registry</gco:CharacterString>\\n'
     '              </gmd:title>\\n'
     '              <gmd:date>\\n'
     '                <gmd:CI_Date>\\n'
     '                  <gmd:date>\\n'
     '                    <gco:Date>2008-11-12</gco:Date>\\n'
     '                  </gmd:date>\\n'
     '                  <gmd:dateType>\\n'
     '                    <gmd:CI_DateTypeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" '
     'codeListValue="publication" '
     'codeSpace="ISOTC211/19115">publication</gmd:CI_DateTypeCode>\\n'
     '                  </gmd:dateType>\\n'
     '                </gmd:CI_Date>\\n'
     '              </gmd:date>\\n'
     '              <gmd:citedResponsibleParty>\\n'
     '                <gmd:CI_ResponsibleParty>\\n'
     '                  <gmd:organisationName>\\n'
     '                    <gco:CharacterString>European Petroleum Survey '
     'Group</gco:CharacterString>\\n'
     '                  </gmd:organisationName>\\n'
     '                  <gmd:contactInfo>\\n'
     '                    <gmd:CI_Contact>\\n'
     '                      <gmd:onlineResource>\\n'
     '                        <gmd:CI_OnlineResource>\\n'
     '                          <gmd:linkage>\\n'
     '                            '
     '<gmd:URL>http://www.epsg-registry.org</gmd:URL>\\n'
     '                          </gmd:linkage>\\n'
     '                        </gmd:CI_OnlineResource>\\n'
     '                      </gmd:onlineResource>\\n'
     '                    </gmd:CI_Contact>\\n'
     '                  </gmd:contactInfo>\\n'
     '                  <gmd:role>\\n'
     '                    <gmd:CI_RoleCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" '
     'codeListValue="originator" '
     'codeSpace="ISOTC211/19115">originator</gmd:CI_RoleCode>\\n'
     '                  </gmd:role>\\n'
     '                </gmd:CI_ResponsibleParty>\\n'
     '              </gmd:citedResponsibleParty>\\n'
     '            </gmd:CI_Citation>\\n'
     '          </gmd:authority>\\n'
     '          <gmd:code>\\n'
     '            '
     '<gco:CharacterString>urn:ogc:def:crs:EPSG:4326</gco:CharacterString>\\n'
     '          </gmd:code>\\n'
     '          <gmd:version>\\n'
     '            <gco:CharacterString>6.18.3</gco:CharacterString>\\n'
     '          </gmd:version>\\n'
     '        </gmd:RS_Identifier>\\n'
     '      </gmd:referenceSystemIdentifier>\\n'
     '    </gmd:MD_ReferenceSystem>\\n'
     '  </gmd:referenceSystemInfo>\\n'
     '  <gmd:identificationInfo>\\n'
     '    <gmd:MD_DataIdentification>\\n'
     '      <gmd:citation>\\n'
     '        <gmd:CI_Citation>\\n'
     '          <gmd:title xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '            <gco:CharacterString>title in English</gco:CharacterString>\\n'
     '            <gmd:PT_FreeText>\\n'
     '              <gmd:textGroup>\\n'
     '                <gmd:LocalisedCharacterString locale="#locale-fr">title in '
     'French</gmd:LocalisedCharacterString>\\n'
     '              </gmd:textGroup>\\n'
     '            </gmd:PT_FreeText>\\n'
     '          </gmd:title>\\n'
     '          <gmd:date>\\n'
     '            <gmd:CI_Date>\\n'
     '              <gmd:date>\\n'
     '                <gco:DateTime>2000-09-01T00:00:00Z</gco:DateTime>\\n'
     '              </gmd:date>\\n'
     '              <gmd:dateType>\\n'
     '                <gmd:CI_DateTypeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode" '
     'codeListValue="publication" '
     'codeSpace="ISOTC211/19115">publication</gmd:CI_DateTypeCode>\\n'
     '              </gmd:dateType>\\n'
     '            </gmd:CI_Date>\\n'
     '          </gmd:date>\\n'
     '        </gmd:CI_Citation>\\n'
     '      </gmd:citation>\\n'
     '      <gmd:abstract xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '        <gco:CharacterString>abstract in English</gco:CharacterString>\\n'
     '        <gmd:PT_FreeText>\\n'
     '          <gmd:textGroup>\\n'
     '            <gmd:LocalisedCharacterString locale="#locale-fr">abstract in '
     'French</gmd:LocalisedCharacterString>\\n'
     '          </gmd:textGroup>\\n'
     '        </gmd:PT_FreeText>\\n'
     '      </gmd:abstract>\\n'
     '      <gmd:status>\\n'
     '        <gmd:MD_ProgressCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_ProgressCode" '
     'codeListValue="onGoing" '
     'codeSpace="ISOTC211/19115">onGoing</gmd:MD_ProgressCode>\\n'
     '      </gmd:status>\\n'
     '      <gmd:resourceMaintenance>\\n'
     '        <gmd:MD_MaintenanceInformation>\\n'
     '          <gmd:maintenanceAndUpdateFrequency>\\n'
     '            <gmd:MD_MaintenanceFrequencyCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode" '
     'codeListValue="continual" '
     'codeSpace="ISOTC211/19115">continual</gmd:MD_MaintenanceFrequencyCode>\\n'
     '          </gmd:maintenanceAndUpdateFrequency>\\n'
     '        </gmd:MD_MaintenanceInformation>\\n'
     '      </gmd:resourceMaintenance>\\n'
     '      <gmd:descriptiveKeywords>\\n'
     '        <gmd:MD_Keywords>\\n'
     '          <gmd:keyword xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '            <gco:CharacterString>kw1 in English</gco:CharacterString>\\n'
     '            <gmd:PT_FreeText>\\n'
     '              <gmd:textGroup>\\n'
     '                <gmd:LocalisedCharacterString locale="#locale-fr">kw1 in '
     'French</gmd:LocalisedCharacterString>\\n'
     '              </gmd:textGroup>\\n'
     '            </gmd:PT_FreeText>\\n'
     '          </gmd:keyword>\\n'
     '          <gmd:keyword xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '            <gco:CharacterString>kw2 in English</gco:CharacterString>\\n'
     '            <gmd:PT_FreeText>\\n'
     '              <gmd:textGroup>\\n'
     '                <gmd:LocalisedCharacterString locale="#locale-fr">kw2 in '
     'French</gmd:LocalisedCharacterString>\\n'
     '              </gmd:textGroup>\\n'
     '            </gmd:PT_FreeText>\\n'
     '          </gmd:keyword>\\n'
     '          <gmd:keyword xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '            <gco:CharacterString>kw3 in English</gco:CharacterString>\\n'
     '            <gmd:PT_FreeText>\\n'
     '              <gmd:textGroup>\\n'
     '                <gmd:LocalisedCharacterString locale="#locale-fr">kw3 in '
     'French</gmd:LocalisedCharacterString>\\n'
     '              </gmd:textGroup>\\n'
     '            </gmd:PT_FreeText>\\n'
     '          </gmd:keyword>\\n'
     '          <gmd:type>\\n'
     '            <gmd:MD_KeywordTypeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode" '
     'codeListValue="theme" '
     'codeSpace="ISOTC211/19115">theme</gmd:MD_KeywordTypeCode>\\n'
     '          </gmd:type>\\n'
     '        </gmd:MD_Keywords>\\n'
     '      </gmd:descriptiveKeywords>\\n'
     '      <gmd:resourceConstraints>\\n'
     '        <gmd:MD_LegalConstraints>\\n'
     '          <gmd:accessConstraints>\\n'
     '            <gmd:MD_RestrictionCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" '
     'codeListValue="otherRestrictions" '
     'codeSpace="ISOTC211/19115">otherRestrictions</gmd:MD_RestrictionCode>\\n'
     '          </gmd:accessConstraints>\\n'
     '        </gmd:MD_LegalConstraints>\\n'
     '      </gmd:resourceConstraints>\\n'
     '      <gmd:spatialRepresentationType>\\n'
     '        <gmd:MD_SpatialRepresentationTypeCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_SpatialRepresentationTypeCode" '
     'codeListValue="vector" '
     'codeSpace="ISOTC211/19115">vector</gmd:MD_SpatialRepresentationTypeCode>\\n'
     '      </gmd:spatialRepresentationType>\\n'
     '      <gmd:language>\\n'
     '        <gco:CharacterString>eng; CAN</gco:CharacterString>\\n'
     '      </gmd:language>\\n'
     '      <gmd:characterSet>\\n'
     '        <gmd:MD_CharacterSetCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_CharacterSetCode" '
     'codeListValue="utf8" '
     'codeSpace="ISOTC211/19115">utf8</gmd:MD_CharacterSetCode>\\n'
     '      </gmd:characterSet>\\n'
     '      <gmd:topicCategory>\\n'
     '        '
     '<gmd:MD_TopicCategoryCode>climatologyMeteorologyAtmosphere</gmd:MD_TopicCategoryCode>\\n'
     '      </gmd:topicCategory>\\n'
     '      <gmd:extent>\\n'
     '        <gmd:EX_Extent>\\n'
     '          <gmd:geographicElement>\\n'
     '            <gmd:EX_GeographicBoundingBox>\\n'
     '              <gmd:extentTypeCode>\\n'
     '                <gco:Boolean>1</gco:Boolean>\\n'
     '              </gmd:extentTypeCode>\\n'
     '              <gmd:westBoundLongitude>\\n'
     '                <gco:Decimal>-141</gco:Decimal>\\n'
     '              </gmd:westBoundLongitude>\\n'
     '              <gmd:eastBoundLongitude>\\n'
     '                <gco:Decimal>-52</gco:Decimal>\\n'
     '              </gmd:eastBoundLongitude>\\n'
     '              <gmd:southBoundLatitude>\\n'
     '                <gco:Decimal>42</gco:Decimal>\\n'
     '              </gmd:southBoundLatitude>\\n'
     '              <gmd:northBoundLatitude>\\n'
     '                <gco:Decimal>84</gco:Decimal>\\n'
     '              </gmd:northBoundLatitude>\\n'
     '            </gmd:EX_GeographicBoundingBox>\\n'
     '          </gmd:geographicElement>\\n'
     '          <gmd:temporalElement>\\n'
     '            <gmd:EX_TemporalExtent>\\n'
     '              <gmd:extent>\\n'
     '                <gml:TimePeriod gml:id="T001">\\n'
     '                  <gml:beginPosition>1950-07-31</gml:beginPosition>\\n'
     '                  <gml:endPosition indeterminatePosition="now"/>\\n'
     '                </gml:TimePeriod>\\n'
     '              </gmd:extent>\\n'
     '            </gmd:EX_TemporalExtent>\\n'
     '          </gmd:temporalElement>\\n'
     '        </gmd:EX_Extent>\\n'
     '      </gmd:extent>\\n'
     '      <gmd:supplementalInformation>\\n'
     '        '
     '<gco:CharacterString>http://geogratis.ca/geogratis/en/product/search.do?id=08DB5E85-7405-FE3A-2860-CC3663245625</gco:CharacterString>\\n'
     '      </gmd:supplementalInformation>\\n'
     '    </gmd:MD_DataIdentification>\\n'
     '  </gmd:identificationInfo>\\n'
     '  <gmd:distributionInfo>\\n'
     '    <gmd:MD_Distribution>\\n'
     '      <gmd:distributor>\\n'
     '        <gmd:MD_Distributor>\\n'
     '          <gmd:distributorContact>\\n'
     '            <gmd:CI_ResponsibleParty>\\n'
     '              <gmd:individualName>\\n'
     '                <gco:CharacterString>Tom Kralidis</gco:CharacterString>\\n'
     '              </gmd:individualName>\\n'
     '              <gmd:organisationName>\\n'
     '                <gco:CharacterString>Environment '
     'Canada</gco:CharacterString>\\n'
     '              </gmd:organisationName>\\n'
     '              <gmd:positionName>\\n'
     '                <gco:CharacterString>Senior Systems '
     'Scientist</gco:CharacterString>\\n'
     '              </gmd:positionName>\\n'
     '              <gmd:contactInfo>\\n'
     '                <gmd:CI_Contact>\\n'
     '                  <gmd:phone>\\n'
     '                    <gmd:CI_Telephone>\\n'
     '                      <gmd:voice>\\n'
     '                        '
     '<gco:CharacterString>+01-123-456-7890</gco:CharacterString>\\n'
     '                      </gmd:voice>\\n'
     '                      <gmd:facsimile>\\n'
     '                        '
     '<gco:CharacterString>+01-123-456-7890</gco:CharacterString>\\n'
     '                      </gmd:facsimile>\\n'
     '                    </gmd:CI_Telephone>\\n'
     '                  </gmd:phone>\\n'
     '                  <gmd:address>\\n'
     '                    <gmd:CI_Address>\\n'
     '                      <gmd:deliveryPoint>\\n'
     '                        <gco:CharacterString>4905 Dufferin '
     'Street</gco:CharacterString>\\n'
     '                      </gmd:deliveryPoint>\\n'
     '                      <gmd:city>\\n'
     '                        '
     '<gco:CharacterString>Toronto</gco:CharacterString>\\n'
     '                      </gmd:city>\\n'
     '                      <gmd:administrativeArea>\\n'
     '                        '
     '<gco:CharacterString>Ontario</gco:CharacterString>\\n'
     '                      </gmd:administrativeArea>\\n'
     '                      <gmd:postalCode>\\n'
     '                        <gco:CharacterString>M3H '
     '5T4</gco:CharacterString>\\n'
     '                      </gmd:postalCode>\\n'
     '                      <gmd:country>\\n'
     '                        <gco:CharacterString>Canada</gco:CharacterString>\\n'
     '                      </gmd:country>\\n'
     '                      <gmd:electronicMailAddress>\\n'
     '                        '
     '<gco:CharacterString>[email protected]</gco:CharacterString>\\n'
     '                      </gmd:electronicMailAddress>\\n'
     '                    </gmd:CI_Address>\\n'
     '                  </gmd:address>\\n'
     '                  <gmd:onlineResource>\\n'
     '                    <gmd:CI_OnlineResource>\\n'
     '                      <gmd:linkage>\\n'
     '                        <gmd:URL>http://www.ec.gc.ca/</gmd:URL>\\n'
     '                      </gmd:linkage>\\n'
     '                      <gmd:protocol>\\n'
     '                        '
     '<gco:CharacterString>WWW:LINK</gco:CharacterString>\\n'
     '                      </gmd:protocol>\\n'
     '                    </gmd:CI_OnlineResource>\\n'
     '                  </gmd:onlineResource>\\n'
     '                  <gmd:hoursOfService>\\n'
     '                    <gco:CharacterString>0700h - 1500h '
     'EST</gco:CharacterString>\\n'
     '                  </gmd:hoursOfService>\\n'
     '                  <gmd:contactInstructions>\\n'
     '                    <gco:CharacterString>email</gco:CharacterString>\\n'
     '                  </gmd:contactInstructions>\\n'
     '                </gmd:CI_Contact>\\n'
     '              </gmd:contactInfo>\\n'
     '              <gmd:role>\\n'
     '                <gmd:CI_RoleCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_RoleCode" '
     'codeListValue="distributor" '
     'codeSpace="ISOTC211/19115">distributor</gmd:CI_RoleCode>\\n'
     '              </gmd:role>\\n'
     '            </gmd:CI_ResponsibleParty>\\n'
     '          </gmd:distributorContact>\\n'
     '        </gmd:MD_Distributor>\\n'
     '      </gmd:distributor>\\n'
     '      <gmd:transferOptions>\\n'
     '        <gmd:MD_DigitalTransferOptions>\\n'
     '          <gmd:onLine>\\n'
     '            <gmd:CI_OnlineResource>\\n'
     '              <gmd:linkage>\\n'
     '                <gmd:URL>http://dd.meteo.gc.ca</gmd:URL>\\n'
     '              </gmd:linkage>\\n'
     '              <gmd:protocol>\\n'
     '                <gco:CharacterString>WWW:LINK</gco:CharacterString>\\n'
     '              </gmd:protocol>\\n'
     '              <gmd:name>\\n'
     '                <gco:CharacterString>my waf</gco:CharacterString>\\n'
     '              </gmd:name>\\n'
     '              <gmd:description xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '                <gco:CharacterString>description in '
     'English</gco:CharacterString>\\n'
     '                <gmd:PT_FreeText>\\n'
     '                  <gmd:textGroup>\\n'
     '                    <gmd:LocalisedCharacterString '
     'locale="#locale-fr">description in French</gmd:LocalisedCharacterString>\\n'
     '                  </gmd:textGroup>\\n'
     '                </gmd:PT_FreeText>\\n'
     '              </gmd:description>\\n'
     '              <gmd:function>\\n'
     '                <gmd:CI_OnLineFunctionCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode" '
     'codeListValue="download" '
     'codeSpace="ISOTC211/19115">download</gmd:CI_OnLineFunctionCode>\\n'
     '              </gmd:function>\\n'
     '            </gmd:CI_OnlineResource>\\n'
     '          </gmd:onLine>\\n'
     '          <gmd:onLine>\\n'
     '            <gmd:CI_OnlineResource>\\n'
     '              <gmd:linkage>\\n'
     '                <gmd:URL>http://dd.meteo.gc.ca</gmd:URL>\\n'
     '              </gmd:linkage>\\n'
     '              <gmd:protocol>\\n'
     '                <gco:CharacterString>OGC:WMS</gco:CharacterString>\\n'
     '              </gmd:protocol>\\n'
     '              <gmd:name xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '                <gco:CharacterString>roads</gco:CharacterString>\\n'
     '                <gmd:PT_FreeText>\\n'
     '                  <gmd:textGroup>\\n'
     '                    <gmd:LocalisedCharacterString '
     'locale="#locale-fr">routes</gmd:LocalisedCharacterString>\\n'
     '                  </gmd:textGroup>\\n'
     '                </gmd:PT_FreeText>\\n'
     '              </gmd:name>\\n'
     '              <gmd:description xsi:type="gmd:PT_FreeText_PropertyType">\\n'
     '                <gco:CharacterString>description in '
     'English</gco:CharacterString>\\n'
     '                <gmd:PT_FreeText>\\n'
     '                  <gmd:textGroup>\\n'
     '                    <gmd:LocalisedCharacterString '
     'locale="#locale-fr">description in French</gmd:LocalisedCharacterString>\\n'
     '                  </gmd:textGroup>\\n'
     '                </gmd:PT_FreeText>\\n'
     '              </gmd:description>\\n'
     '              <gmd:function>\\n'
     '                <gmd:CI_OnLineFunctionCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#CI_OnLineFunctionCode" '
     'codeListValue="download" '
     'codeSpace="ISOTC211/19115">download</gmd:CI_OnLineFunctionCode>\\n'
     '              </gmd:function>\\n'
     '            </gmd:CI_OnlineResource>\\n'
     '          </gmd:onLine>\\n'
     '        </gmd:MD_DigitalTransferOptions>\\n'
     '      </gmd:transferOptions>\\n'
     '    </gmd:MD_Distribution>\\n'
     '  </gmd:distributionInfo>\\n'
     '  <gmd:metadataMaintenance>\\n'
     '    <gmd:MD_MaintenanceInformation>\\n'
     '      <gmd:maintenanceAndUpdateFrequency>\\n'
     '        <gmd:MD_MaintenanceFrequencyCode '
     'codeList="http://www.isotc211.org/2005/resources/Codelist/gmxCodelists.xml#MD_MaintenanceFrequencyCode" '
     'codeListValue="continual" '
     'codeSpace="ISOTC211/19115">continual</gmd:MD_MaintenanceFrequencyCode>\\n'
     '      </gmd:maintenanceAndUpdateFrequency>\\n'
     '      <gmd:maintenanceNote>\\n'
     '        <gco:CharacterString>This metadata record was generated by '
     'pygeometa-... '
     '(https://github.com/geopython/pygeometa)</gco:CharacterString>\\n'
     '      </gmd:maintenanceNote>\\n'
     '    </gmd:MD_MaintenanceInformation>\\n'
     '  </gmd:metadataMaintenance>\\n'
     '</gmd:MD_Metadata>')
    """
    iso19139_jinja_dir = os.path.dirname(__file__)  # Jinja2 templates to
    # generate WCODP-compliant Geographic MetaData (GMD) XML are stored in
    # the same directory as this Python module.
    with NamedTemporaryFile() as fp:
        fp.write(metadata_control.encode('utf-8'))
        fp.seek(0)  #reset file-pointer, for reading
        temp_file_name = fp.name
        xml = render_template(temp_file_name, schema_local=iso19139_jinja_dir)
    return xml