@@ -1409,4 +1409,42 @@ void testPDFBox6131() throws IOException, XmpParsingException, BadFieldValueExce
14091409 assertEquals (1 , uaSchema2 .getIntegerPropertyValueAsSimple ("part" ));
14101410 }
14111411 }
1412+
1413+ /**
1414+ * This worked in 3.0.6 in lenient mode, temporarly no longer worked while doing the changes in
1415+ * getSpecifiedPropertyType() in PDFBOX-6133. However "photoshop:headline" should be a text, not
1416+ * a Seq, and it's "Headline" with a capital H. The cause is that the photoshop namespace exists
1417+ * both as a schema and as a type.
1418+ *
1419+ * @throws XmpParsingException
1420+ */
1421+ @ Test
1422+ void testWrongType () throws XmpParsingException
1423+ {
1424+ // from file 000367.pdf, USAID document
1425+ String s =
1426+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
1427+ "<?xpacket begin=\" \" id=\" W5M0MpCehiHzreSzNTczkc9d\" ?><x:xmpmeta xmlns:x=\" adobe:ns:meta/\" x:xmptk=\" Adobe XMP Core 4.0-c316 44.253921, Sun Oct 01 2006 17:14:39\" >\n " +
1428+ " <rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
1429+ " <rdf:Description xmlns:photoshop=\" http://ns.adobe.com/photoshop/1.0/\" rdf:about=\" \" >\n " +
1430+ " <photoshop:headline>\n " +
1431+ " <rdf:Seq>\n " +
1432+ " <rdf:li/>\n " +
1433+ " </rdf:Seq>\n " +
1434+ " </photoshop:headline>\n " +
1435+ " </rdf:Description>\n " +
1436+ " </rdf:RDF>\n " +
1437+ "</x:xmpmeta><?xpacket end=\" w\" ?>" ;
1438+ final DomXmpParser xmpParser1 = new DomXmpParser ();
1439+ XmpParsingException ex = assertThrows (XmpParsingException .class ,
1440+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
1441+ assertEquals ("No type defined for {http://ns.adobe.com/photoshop/1.0/}headline" , ex .getMessage ());
1442+ final DomXmpParser xmpParser2 = new DomXmpParser ();
1443+ xmpParser2 .setStrictParsing (false );
1444+ XMPMetadata xmp2 = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
1445+ PhotoshopSchema photoshopSchema = xmp2 .getPhotoshopSchema ();
1446+ assertNull (photoshopSchema .getHeadline ());
1447+ // non existant properties are treated as text, one might want to change this in the future.
1448+ assertEquals ("[headline=TextType:]" , photoshopSchema .getProperty ("headline" ).toString ());
1449+ }
14121450}
0 commit comments