@@ -1022,4 +1022,44 @@ void testNonStandardURIinRDF() throws XmpParsingException, TransformerException
10221022 XMPSchema schema4 = xmp4 .getSchema ("http://ns.adobe.com/pdfx/1.3/" );
10231023 assertEquals ("[XPressPrivate=TextType:private]" , schema4 .getProperty ("XPressPrivate" ).toString ());
10241024 }
1025+
1026+ /**
1027+ * Test empty property where an LangAlt is expected. The property is skipped in lenient mode.
1028+ *
1029+ * @throws XmpParsingException
1030+ * @throws TransformerException
1031+ * @throws BadFieldValueException
1032+ */
1033+ @ Test
1034+ void testBadProp () throws XmpParsingException , TransformerException , BadFieldValueException
1035+ {
1036+ String s = "<?xml version=\" 1.0\" encoding=\" UTF-8\" standalone=\" no\" ?>\n " +
1037+ "<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' bytes='1506'?><rdf:RDF xmlns:rdf=\" http://www.w3.org/1999/02/22-rdf-syntax-ns#\" xmlns:iX=\" http://ns.adobe.com/iX/1.0/\" >\n " +
1038+ " <rdf:Description xmlns=\" http://purl.org/dc/elements/1.1/\" xmlns:dc=\" http://purl.org/dc/elements/1.1/\" about=\" \" >\n " +
1039+ " <dc:creator/>\n " +
1040+ " <dc:coverage>Cover</dc:coverage>\n " +
1041+ " </rdf:Description>\n " +
1042+ "</rdf:RDF><?xpacket end='r'?>" ;
1043+ final DomXmpParser xmpParser1 = new DomXmpParser ();
1044+ XmpParsingException ex = assertThrows (XmpParsingException .class ,
1045+ () -> xmpParser1 .parse (s .getBytes (StandardCharsets .UTF_8 )));
1046+ assertEquals ("Invalid array definition, expecting Seq and found nothing [prefix=dc; name=creator]" , ex .getMessage ());
1047+ DomXmpParser xmpParser2 = new DomXmpParser ();
1048+ xmpParser2 .setStrictParsing (false );
1049+ XMPMetadata xmp2 = xmpParser2 .parse (s .getBytes (StandardCharsets .UTF_8 ));
1050+ DublinCoreSchema dublinCoreSchema2 = xmp2 .getDublinCoreSchema ();
1051+ assertNull (dublinCoreSchema2 .getCreators ());
1052+ assertNull (dublinCoreSchema2 .getProperty (DublinCoreSchema .CREATOR ));
1053+ assertEquals ("Cover" , dublinCoreSchema2 .getCoverage ());
1054+ XmpSerializer serializer = new XmpSerializer ();
1055+ ByteArrayOutputStream baos = new ByteArrayOutputStream ();
1056+ serializer .serialize (xmp2 , baos , true );
1057+ DomXmpParser xmpParser3 = new DomXmpParser ();
1058+ xmpParser3 .setStrictParsing (false );
1059+ XMPMetadata xmp3 = xmpParser3 .parse (baos .toByteArray ());
1060+ DublinCoreSchema dublinCoreSchema3 = xmp3 .getDublinCoreSchema ();
1061+ assertNull (dublinCoreSchema3 .getCreators ());
1062+ assertNull (dublinCoreSchema3 .getProperty (DublinCoreSchema .CREATOR ));
1063+ assertEquals ("Cover" , dublinCoreSchema3 .getCoverage ());
1064+ }
10251065}
0 commit comments