geopython / OWSLib

OWSLib is a Python package for client programming with Open Geospatial Consortium (OGC) web service (hence OWS) interface standards, and their related content models.
https://owslib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
386 stars 275 forks source link

XMLSyntaxError when format is JSON in CSW request #493

Open jankovicgd opened 6 years ago

jankovicgd commented 6 years ago

I am trying to get a record in JSON but getting a XMLSyntaxError. The default format works. Sending a simple GET with outputFormat=application/json also works.

Input

csw = CatalogueServiceWeb(url)
csw.getrecordbyid(id=[id], 
                  outputschema='http://www.isotc211.org/2005/gmd', 
                  format='application/json')

Output

Traceback (most recent call last):
  File "/home/nikola/.local/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-3-ae9f74e2d058>", line 2, in <module>
    outputschema='http://www.isotc211.org/2005/gmd', format='application/json')
  File "/usr/lib/python3/dist-packages/owslib/csw.py", line 301, in getrecordbyid
    self._invoke()
  File "/usr/lib/python3/dist-packages/owslib/csw.py", line 680, in _invoke
    self._exml = etree.parse(BytesIO(self.response))
  File "src/lxml/etree.pyx", line 3426, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1856, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1876, in lxml.etree._parseMemoryDocument
  File "src/lxml/parser.pxi", line 1764, in lxml.etree._parseDoc
  File "src/lxml/parser.pxi", line 1126, in lxml.etree._BaseParser._parseDoc
  File "src/lxml/parser.pxi", line 600, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 710, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 639, in lxml.etree._raiseParseError
  File "<string>", line 1
XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1

Additional info

Running on Ubuntu 18.04 in a jupyter notebook with python 3.6.5.

Thanks in advance.

tomkralidis commented 6 years ago

Is there a CSW we can test against?

jankovicgd commented 6 years ago

Thanks for the fast reply.

I am connecting at https://csw.eodc.eu/ Below is an ID. M20170123_202730--_SIG0-----_S1BIWGRDH1VVD_104_A0101_OC010M_E070N065T1

jankovicgd commented 1 year ago

Hey, any progress here? I am getting a different error now.

Traceback (most recent call last):
  File "/home/nikola/Tests/owslib_test/test.py", line 7, in <module>
    csw.getrecordbyid(id=[id], 
  File "/home/nikola/Tests/owslib_test/.venv/lib/python3.10/site-packages/owslib/catalogue/csw2.py", line 304, in getrecordbyid
    self._invoke()
  File "/home/nikola/Tests/owslib_test/.venv/lib/python3.10/site-packages/owslib/catalogue/csw2.py", line 708, in _invoke
    self._exml = etree.parse(BytesIO(self.response))
  File "/home/nikola/.pyenv/versions/3.10.4/lib/python3.10/xml/etree/ElementTree.py", line 1229, in parse
    tree.parse(source, parser)
  File "/home/nikola/.pyenv/versions/3.10.4/lib/python3.10/xml/etree/ElementTree.py", line 580, in parse
    self._root = parser._parse_whole(source)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 1, column 0
github-actions[bot] commented 1 week ago

This Issue has been inactive for 90 days. In order to manage maintenance burden, it will be automatically closed in 7 days.