@@ -1072,6 +1072,37 @@ void testBadProp() throws XmpParsingException, TransformerException
10721072 assertEquals ("Cover" , dublinCoreSchema3 .getCoverage ());
10731073 }
10741074
1075+ @ Test
1076+ void testBadProp2 () throws XmpParsingException
1077+ {
1078+ // PDFBOX-6135: from file 000316.pdf, stRef:documentName isn't defined
1079+ String s =
1080+ "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
1081+ "<?xpacket begin=\" \" id=\" W5M0MpCehiHzreSzNTczkc9d\" ?><x:xmpmeta xmlns:x=\" adobe:ns:meta/\" x:xmptk=\" 3.1-701\" >\n " +
1082+ " <rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" >\n " +
1083+ " <rdf:Description xmlns:stRef=\" http://ns.adobe.com/xap/1.0/sType/ResourceRef#\" xmlns:xapMM=\" http://ns.adobe.com/xap/1.0/mm/\" rdf:about=\" \" >\n " +
1084+ " <xapMM:DocumentID>uuid:CE03288B61A6DB11A55CA11F14F48514</xapMM:DocumentID>\n " +
1085+ " <xapMM:InstanceID>uuid:474647e9-680a-47dc-83d5-ba3f3a7e2a67</xapMM:InstanceID>\n " +
1086+ " <xapMM:DerivedFrom rdf:parseType=\" Resource\" >\n " +
1087+ " <stRef:documentName>uuid:8705447f-b80d-4cc8-82f7-0ec27187edfe</stRef:documentName>\n " +
1088+ " <stRef:documentID>uuid:b2f88223-2723-430d-b93c-3503ccb0e34b</stRef:documentID>\n " +
1089+ " </xapMM:DerivedFrom>\n " +
1090+ " </rdf:Description>\n " +
1091+ " </rdf:RDF>\n " +
1092+ "</x:xmpmeta><?xpacket end=\" w\" ?>" ;
1093+ final DomXmpParser xmpParser1 = new DomXmpParser ();
1094+ XmpParsingException ex = assertThrows (XmpParsingException .class ,
1095+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
1096+ assertEquals ("Type 'stRef:documentName' not defined in http://ns.adobe.com/xap/1.0/sType/ResourceRef#" , ex .getMessage ());
1097+ final DomXmpParser xmpParser2 = new DomXmpParser ();
1098+ xmpParser2 .setStrictParsing (false );
1099+ XMPMetadata xmp2 = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
1100+ XMPMediaManagementSchema xmpMediaManagementSchema = xmp2 .getXMPMediaManagementSchema ();
1101+ ResourceRefType derived = xmpMediaManagementSchema .getDerivedFromProperty ();
1102+ assertEquals ("uuid:b2f88223-2723-430d-b93c-3503ccb0e34b" , derived .getDocumentID ());
1103+ assertEquals ("[documentName=TextType:uuid:8705447f-b80d-4cc8-82f7-0ec27187edfe]" , derived .getProperty ("documentName" ).toString ());
1104+ }
1105+
10751106 @ Test
10761107 void testParseFailure () throws XmpParsingException
10771108 {
0 commit comments