Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to define namespaces for xpath using the xqilla commandline tool?
    primarykey
    data
    text
    <p>I am trying to use some xpath expressions to extract info from an XML file that looks like this (it is an OAI-PMH protocol response):</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"&gt; &lt;responseDate&gt;2013-10-11T09:24:55Z&lt;/responseDate&gt; &lt;request verb="ListRecords" metadataPrefix="oai_dc"&gt;http://request.url.com/oai&lt;/request&gt; &lt;ListRecords&gt; &lt;record&gt; &lt;header&gt; &lt;identifier&gt;oai:identifier:item1&lt;/identifier&gt; &lt;datestamp&gt;2012-06-07T12:03:53Z&lt;/datestamp&gt; &lt;setSpec&gt;set:identifier&lt;/setSpec&gt; &lt;/header&gt; &lt;metadata&gt; &lt;oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd"&gt; &lt;dc:title xml:lang="en-US"&gt;Title&lt;/dc:title&gt; &lt;dc:creator&gt;creator&lt;/dc:creator&gt; &lt;dc:description xml:lang="en-US"&gt;abstract&lt;/dc:description&gt; &lt;dc:publisher xml:lang="en-US"&gt;publisher&lt;/dc:publisher&gt; &lt;dc:contributor xml:lang="en-US"&gt;&lt;/dc:contributor&gt; &lt;dc:date&gt;2011-10-18&lt;/dc:date&gt; &lt;dc:type xml:lang="en-US"&gt;&lt;/dc:type&gt; &lt;dc:format&gt;application/pdf&lt;/dc:format&gt; &lt;dc:identifier&gt;identifier&lt;/dc:identifier&gt; &lt;dc:source xml:lang="en-US"&gt;source&lt;/dc:source&gt; &lt;/oai_dc:dc&gt; &lt;/metadata&gt; &lt;/record&gt; &lt;record&gt; ... &lt;/record&gt; ... &lt;/ListRecords&gt; &lt;/OAI-PMH&gt; </code></pre> <p>Ultimately I will have to write some Java code to do this, but I'd like to know more about the xpath and namespaces and for that reason I use the command line tool xqilla.</p> <p>After some research (eg <a href="https://stackoverflow.com/questions/3804055/problem-running-xpath-query-with-namespaces">this</a>) and many failed attempts I tried the following expression:</p> <pre><code>//*[local-name()='title'] </code></pre> <p>but I get the following error:</p> <pre><code>:1:22: error: No namespace for prefix 'xs' [err:XPST0081] </code></pre> <p>Could someone point me to the right direction please? The documentation of <a href="http://xqilla.sourceforge.net/Documentation" rel="nofollow noreferrer">xqilla</a> has not proven very helpful so far.</p> <p>Thanks.</p> <p>Edit: Since the title is not exactly what is being asked here, a follow up (and more general) question would be how does one define namespaces in general using xqilla? Because if I try the expression:</p> <pre><code>//dc:title </code></pre> <p>the error I get is </p> <pre><code>/tmp/foo.xq:1:3: error: No namespace for prefix 'dc' [err:XPST0081] </code></pre> <p>I am running xqilla like this:</p> <pre><code>xqilla -p -i oai_response.xml foo.xq </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload