[
https://issues.apache.org/jira/browse/PDFBOX-5591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17717483#comment-17717483
]
Miroslav Holubec commented on PDFBOX-5591:
------------------------------------------
Possible solution:
{noformat}
private Element findDescriptionsParent(Element root) throws
XmpParsingException {
Element rdfRdf;
if (!XmpConstants.RDF_NAMESPACE.equals(root.getNamespaceURI())) {
// always <x:xmpmeta xmlns:x="adobe:ns:meta/">
expectNaming(root, "adobe:ns:meta/", "x", "xmpmeta");
// should only have one child
NodeList nl = root.getChildNodes();
if (nl.getLength() == 0) {
// empty description
throw new XmpParsingException(ErrorType.Format, "No rdf
description found in xmp");
} else if (nl.getLength() > 1) {
// only expect one element
throw new XmpParsingException(ErrorType.Format, "More than one
element found in x:xmpmeta");
} else if (!(root.getFirstChild() instanceof Element)) {
// should be an element
throw new XmpParsingException(ErrorType.Format, "x:xmpmeta does
not contains rdf:RDF element");
} // else let's parse
rdfRdf = (Element) root.getFirstChild();
} else {
rdfRdf = root;
}
// always <rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
expectNaming(rdfRdf, XmpConstants.RDF_NAMESPACE,
XmpConstants.DEFAULT_RDF_PREFIX, XmpConstants.DEFAULT_RDF_LOCAL_NAME);
// return description parent
return rdfRdf;
}
{noformat}
> Parsing of XMP metadata without optional xmpmeta element
> --------------------------------------------------------
>
> Key: PDFBOX-5591
> URL: https://issues.apache.org/jira/browse/PDFBOX-5591
> Project: PDFBox
> Issue Type: Bug
> Components: XmpBox
> Affects Versions: 2.0.28
> Reporter: Miroslav Holubec
> Priority: Major
>
> As per [XMP
> Specification|https://printtechnologies.org/wp-content/uploads/2020/03/xmp-specification-jan04_fileticket1nrcKq4MTKctabid158mid669.pdf]
> is the _xmpmeta_ element optional:
> The sections below describe the high-level structure of XMP data in an XMP
> Packet:
> * The outermost element is *optionally* an x:xmpmeta element
> * It contains a single rdf:RDF element
> * which in turn contains one or more rdf:Description elements
> * each of which contains one or more XMP Properties.
>
> DomXmpParser requires it as per call to expectNaming(root, "adobe:ns:meta/",
> "x", "xmpmeta");
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]