Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISO metadata parsing error when MD_FeatureCatalogueDescription uuidref attribute is missing #491

Closed
bchartier opened this issue Jul 23, 2018 · 6 comments

Comments

@bchartier
Copy link

I use OWSLib in a tool checking metadata records stored in a CSW catalogue (https://github.com/geobretagne/mdchecker).
When it comes to parse ISO 19139 metadata records containing a gmd:featureCatalogueCitation element with no uuidref attribute an exception is raised by OWSLib (0.16.0):

Traceback (most recent call last):
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/app/mdchecker/main.py", line 510, in quick_test
    metadatas, count, score = ins_wrapper.run_unrecorded_tests()
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/app/mdchecker/main.py", line 290, in run_unrecorded_tests
    maxharvest=self.test_params["maxharvest"]
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/app/mdchecker/inspirobot/Inspirobot.py", line 243, in mdsearch
    maxrecords=maxrecords, outputschema=self.OUTPUTSCHEMA)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/owslib/csw.py", line 399, in getrecords2
    self._parserecords(outputschema, esn)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/owslib/csw.py", line 549, in _parserecords
    self.records[identifier] = MD_Metadata(i)
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/owslib/iso.py", line 146, in __init__
    self.contentinfo.append(MD_FeatureCatalogueDescription(contentinfo))
  File "/Users/benji/dev/projects_current/mdchecker/mdchecker/venv/lib/python2.7/site-packages/owslib/iso.py", line 961, in __init__
    val = i.attrib['uuidref']
  File "src/lxml/lxml.etree.pyx", line 2452, in lxml.etree._Attrib.__getitem__ (src/lxml/lxml.etree.c:70073)
KeyError: 'uuidref'

It seems to me that this attribute is optional as far as ISO 19115 and ISO 19139 are concerned.
OWSLib/iso.py retrieves this attribute this way : val = i.attrib['uuidref'] (see https://github.com/geopython/OWSLib/blob/master/owslib/iso.py#L965). I would suggest to retrieve it with a get function instead (like there: https://github.com/geopython/OWSLib/blob/master/owslib/iso.py#L723).

@Roel
Copy link
Contributor

Roel commented Aug 6, 2018

This is a piece I wrote, I can check and work out a fix in the next couple of days.

@bchartier
Copy link
Author

This is good news. Thank you.

@Roel
Copy link
Contributor

Roel commented Aug 8, 2018

@bchartier Do you maybe have an example you can share of a metadatarecord giving this error?

I checked the gmd schema as well and the uuidref seems indeed to be optional. However, I wonder how you refer to a specific feature catalogue without the uuid reference?

@bchartier
Copy link
Author

Here is an example of such metadatarecord:
https://geobretagne.fr/geonetwork/srv/fre/xml.metadata.get?uuid=955c3e47-411e-4969-b61b-3556d1b9f879

It contains this element:

<gmd:contentInfo>
  <gmd:MD_FeatureCatalogueDescription>
    <gmd:includedWithDataset>
      <gco:Boolean>false</gco:Boolean>
    </gmd:includedWithDataset>
    <gmd:featureCatalogueCitation/>
  </gmd:MD_FeatureCatalogueDescription>
</gmd:contentInfo>

The gmd:featureCatalogueCitation element is present but empty which seems to be compliant to ISO 19139. I don't know why this metadatarecord has been written like this. I'm not its author. I just want to be able to parse it.

Roel pushed a commit to Roel/OWSLib that referenced this issue Aug 14, 2018
This commit fixes the ISO metadata parsing for records that contain an
empty gmd:featureCatalogueCitation element.

It also adds tests for ISO metadata parsing as to ensure not to break
existing functionality in the future. Tests are added for two ISO
metadata records: one from DOV (already existing in the testdata) and
one from GéoBretage.

Closes issue geopython#491.
Roel pushed a commit to Roel/OWSLib that referenced this issue Aug 16, 2018
This commit fixes the ISO metadata parsing for records that contain an
empty gmd:featureCatalogueCitation element.

It also adds tests for ISO metadata parsing as to ensure not to break
existing functionality in the future. Tests are added for two ISO
metadata records: one from DOV (already existing in the testdata) and
one from GéoBretage.

Closes issue geopython#491.
@cehbrecht
Copy link
Contributor

Fixed by PR #502.

@bchartier
Copy link
Author

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants