DSpace / xoai

OAI-PMH Java Toolkit
29 stars 52 forks source link

Improve handling of XML namespaces #48

Closed MattBlissett closed 7 years ago

MattBlissett commented 9 years ago

This fixes an issue I had serving metadata documents like this:

<?xml version='1.0' encoding='UTF-8'?>
<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">
    <dc:title>Invasive Lithobates catesbeianus - American bullfrog occurrences in Flanders</dc:title>
    <dc:subject>Occurrence</dc:subject>
    <dc:subject>Observation</dc:subject>
</oai_dc:dc>

which would become this:

<?xml version='1.0' encoding='UTF-8'?>
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" 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">
    <dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">Invasive Lithobates catesbeianus - American bullfrog occurrences in Flanders</dc:title>
    <dc:subject>Occurrence</dc:subject>
    <dc:subject>Observation</dc:subject>
</oai_dc:dc>

That's invalid — the dc namespace declaration has been lost from the root element, added to the <dc:title>, but not added to the <dc:subject>.

After the patch, the result is the same as the input.