Skip to content

Commit 9d0a2b7

Browse files
committed
PDFBOX-5976: support more namespaces
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1924521 13f79535-47bb-0310-9956-ffa450edef68
1 parent ffb050a commit 9d0a2b7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,11 @@ protected void push(Element description)
952952
{
953953
map.put(no.getLocalName(), no.getValue());
954954
}
955+
else if (no.getNamespaceURI() != null && no.getPrefix() != null)
956+
{
957+
// PDFBOX-5976
958+
map.put(no.getPrefix(), no.getNamespaceURI());
959+
}
955960
}
956961
stack.push(map);
957962
}

xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import java.io.IOException;
2525
import java.io.InputStream;
26+
import java.io.UnsupportedEncodingException;
2627

2728
import org.apache.xmpbox.XMPMetadata;
2829

@@ -63,4 +64,23 @@ void testPDFBox5835() throws IOException, XmpParsingException
6364
Assertions.assertEquals((Integer) 3, xmp.getPDFAIdentificationSchema().getPart());
6465
}
6566
}
67+
68+
@Test
69+
void testPDFBox5976() throws XmpParsingException, UnsupportedEncodingException
70+
{
71+
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
72+
"<?xpacket begin=\"\" id=\"W5M0MpCehiHzreSzNTczkc9d\"?>\n" +
73+
"<rdf:RDF\n" +
74+
" xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n" +
75+
" xmlns:pdf=\"http://ns.adobe.com/pdf/1.3/\"\n" +
76+
" xmlns:pdfaid=\"http://www.aiim.org/pdfa/ns/id/\">\n" +
77+
" <rdf:Description pdfaid:conformance=\"B\" pdfaid:part=\"3\" rdf:about=\"\"/>\n" +
78+
" <rdf:Description pdf:Producer=\"WeasyPrint 64.1\" rdf:about=\"\"/>\n" +
79+
"</rdf:RDF>\n" +
80+
"<?xpacket end=\"r\"?>";
81+
DomXmpParser xmpParser = new DomXmpParser();
82+
XMPMetadata xmp = xmpParser.parse(s.getBytes("utf-8"));
83+
Assertions.assertEquals("B", xmp.getPDFAIdentificationSchema().getConformance());
84+
Assertions.assertEquals((Integer) 3, xmp.getPDFAIdentificationSchema().getPart());
85+
}
6686
}

0 commit comments

Comments
 (0)