<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi all,<br>
<br>
I am trying to insert a metadata in GeoNetwork, according <a
href="https://geopython.github.io/OWSLib/">OWSlib documentation</a>
but it fails with this error message :<br>
<tt>RuntimeError: Document is XML, but not CSW-ish</tt><br>
<br>
But above all, i think quotes are missing in the csw transaction.
you should write :<br>
<div class="highlight-python">
<div class="highlight">
<pre><span class="gp">>>> </span><span class="n">csw</span><span class="o">.</span><span class="n">transaction</span><span class="p">(</span><span class="n">ttype</span><span class="o">=</span><span class="s">'insert'</span><span class="p">,</span> <span class="n">typename</span><span class="o">=</span><span class="s">'gmd:MD_Metadata'</span><span class="p">,</span> <span class="n">record</span><span class="o">=</span><span class="nb">open</span><span class="p">(</span><span class="nb">"file</span><span class="o">.</span><span class="n">xml</span><span class="p">")</span><span class="o">.</span><span class="n">read</span><span class="p">())
instead of :
</span><span class="gp">>>> </span><span class="n">csw</span><span class="o">.</span><span class="n">transaction</span><span class="p">(</span><span class="n">ttype</span><span class="o">=</span><span class="s">'insert'</span><span class="p">,</span> <span class="n">typename</span><span class="o">=</span><span class="s">'gmd:MD_Metadata'</span><span class="p">,</span> <span class="n">record</span><span class="o">=</span><span class="nb">open</span><span class="p">(</span><span class="nb">file</span><span class="o">.</span><span class="n">xml</span><span class="p">)</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
</pre>
</div>
</div>
<br>
Next i recovered a file from another GeoNetwork, in order to be sure
that the metadata file would be correct.<br>
<br>
<tt>wget
<a class="moz-txt-link-freetext" href="https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/xml.metadata.get?id=17804">https://georchestra-mshe.univ-fcomte.fr/geonetwork/srv/fre/xml.metadata.get?id=17804</a>
-O metadata.xml</tt><br>
<br>
And then i tried to insert this metadata in my GeoNetwork Dev
machine :<br>
<br>
<tt>>>> geonetwork =
'<a class="moz-txt-link-freetext" href="http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw">http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw</a>'</tt><tt><br>
</tt><tt>>>> from owslib.csw import CatalogueServiceWeb</tt><tt><br>
</tt><tt>>>> csw = CatalogueServiceWeb(geonetwork)</tt><tt><br>
</tt><tt>>>> csw.transaction(ttype='insert',
typename='gmd:MD_Metadata', record=open("metadata.xml").read())</tt><tt><br>
</tt><tt>Traceback (most recent call last):</tt><tt><br>
</tt><tt> File "<stdin>", line 1, in <module></tt><tt><br>
</tt><tt> File "/usr/lib/python2.7/dist-packages/owslib/csw.py",
line 446, in transaction</tt><tt><br>
</tt><tt> self._invoke()</tt><tt><br>
</tt><tt> File "/usr/lib/python2.7/dist-packages/owslib/csw.py",
line 680, in _invoke</tt><tt><br>
</tt><tt> raise RuntimeError('Document is XML, but not CSW-ish')</tt><tt><br>
</tt><tt>RuntimeError: Document is XML, but not CSW-ish</tt><tt><br>
</tt><br>
Can anybody explain to me why my metadata.xml file is not CSW-ish ?<br>
<br>
Thanks in advance,<br>
<br>
Ernest.<br>
<br>
<pre class="moz-signature" cols="72">--
Ernest CHIARELLO - <a class="moz-txt-link-abbreviated" href="mailto:Ernest.Chiarello@univ-fcomte.fr">Ernest.Chiarello@univ-fcomte.fr</a>
UMR6049 ThéMA - Théoriser et Modéliser pour Aménager
CNRS / université de Bourgogne Franche-Comté
32 rue Mégevand 25030 BESANÇON Cedex
Tel : 03 81 66 54 80 Mob : 07 82 99 11 08
</pre>
</body>
</html>