I got some xmp XML from JPEG image and I want to read and update metadata in it. I've written a pretty SAX parser which can read data, but then I realized that I can't update data with it.
So I went to dom4j. When I tried to parse my XML with it, it throwed an exception about unknown namespaces. A "direct developer" said that I just need to add those namespaces manually, but what if I meet an image with different namespace's url? I wouldn't be able to deal with it?
Then I tried jdom. It created document successfully, but again, I need to know a namespace url in order to get a child tag with it. Here is a quick example of what I am talking about:
document.getRootElement().getChild("RDF", Namespace.getNamespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"))
So, what should I do in order to solve my problem?
- Pray about url's will allways be the same?
- Manually update with only sax?
- Find a library which don't cares about namespaces?
Here is a an xmp XML example:
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c011 79.156380, 2014/05/21-23:38:37 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:exifEX="http://cipa.jp/exif/1.0/" dc:format="image/jpeg" xmp:CreatorTool="Image Data Converter" xmp:ModifyDate="2015-12-25T22:43:26" xmp:CreateDate="2015-12-18T17:02:15" xmp:MetadataDate="2016-02-03T00:31:43+03:00" photoshop:DateCreated="2015-12-18T17:02:15" xmpMM:DocumentID="8845A702F6819ABAE2AF7D36E005DFDF" xmpMM:OriginalDocumentID="8845A702F6819ABAE2AF7D36E005DFDF" xmpMM:InstanceID="xmp.iid:f27bf752-4ea3-df4c-9c2a-b9837267e444" exifEX:PhotographicSensitivity="800">
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">dEscription</rdf:li>
</rdf:Alt>
</dc:description>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">nAme</rdf:li>
</rdf:Alt>
</dc:title>
<dc:creator>
<rdf:Seq>
<rdf:li>aUthor</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:subject>
<rdf:Bag>
<rdf:li>kEyword</rdf:li>
<rdf:li>keYwords2</rdf:li>
</rdf:Bag>
</dc:subject>
<xmpMM:History>
<rdf:Seq>
<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:b6e2ef4c-c0fe-7549-8c9e-b8b8fe89f1ff" stEvt:when="2016-02-02T22:37:17+03:00" stEvt:softwareAgent="Adobe Photoshop Camera Raw 9.4" stEvt:changed="/metadata"/>
<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:f27bf752-4ea3-df4c-9c2a-b9837267e444" stEvt:when="2016-02-03T00:31:43+03:00" stEvt:softwareAgent="Adobe Photoshop Camera Raw 9.4 (Windows)" stEvt:changed="/metadata"/>
</rdf:Seq>
</xmpMM:History>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>