@@ -153,13 +153,10 @@ public XMPMetadata parse(InputStream input) throws XmpParsingException
153153 {
154154 throw new XmpParsingException (ErrorType .XpacketBadStart , "xmp should start with a processing instruction" );
155155 }
156- else
157- {
158- xmp = XMPMetadata .createXMPMetadata (XmpConstants .DEFAULT_XPACKET_BEGIN ,
159- XmpConstants .DEFAULT_XPACKET_ID ,
160- XmpConstants .DEFAULT_XPACKET_BYTES ,
161- XmpConstants .DEFAULT_XPACKET_ENCODING );
162- }
156+ xmp = XMPMetadata .createXMPMetadata (XmpConstants .DEFAULT_XPACKET_BEGIN ,
157+ XmpConstants .DEFAULT_XPACKET_ID ,
158+ XmpConstants .DEFAULT_XPACKET_BYTES ,
159+ XmpConstants .DEFAULT_XPACKET_ENCODING );
163160 }
164161 else
165162 {
@@ -190,10 +187,7 @@ public XMPMetadata parse(InputStream input) throws XmpParsingException
190187 {
191188 throw new XmpParsingException (ErrorType .XpacketBadEnd , "xmp should end with a processing instruction" );
192189 }
193- else
194- {
195- xmp .setEndXPacket (XmpConstants .DEFAULT_XPACKET_END );
196- }
190+ xmp .setEndXPacket (XmpConstants .DEFAULT_XPACKET_END );
197191 }
198192 else
199193 {
@@ -215,15 +209,12 @@ public XMPMetadata parse(InputStream input) throws XmpParsingException
215209 if (!strictParsing )
216210 {
217211 NamedNodeMap nnm = rdfRdf .getAttributes ();
218- if ( nnm != null )
212+ for ( int i = 0 ; i < nnm . getLength (); i ++ )
219213 {
220- for (int i = 0 ; i < nnm .getLength (); i ++)
214+ Attr attr = (Attr ) nnm .item (i );
215+ if (XMLConstants .XMLNS_ATTRIBUTE .equals (attr .getPrefix ()))
221216 {
222- Attr attr = (Attr ) nnm .item (i );
223- if (XMLConstants .XMLNS_ATTRIBUTE .equals (attr .getPrefix ()))
224- {
225- maybeAddNonStandardNamespace (xmp , attr );
226- }
217+ maybeAddNonStandardNamespace (xmp , attr );
227218 }
228219 }
229220 }
@@ -378,11 +369,8 @@ private void parseDescriptionRootAttr(XMPMetadata xmp, Element description, Attr
378369 throw new XmpParsingException (ErrorType .InvalidType , "No type defined for {" + attr .getNamespaceURI () + "}"
379370 + attr .getLocalName ());
380371 }
381- else
382- {
383- // PDFBOX-2318, PDFBOX-6106: Default to text if no type is found
384- type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
385- }
372+ // PDFBOX-2318, PDFBOX-6106: Default to text if no type is found
373+ type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
386374 }
387375 else if (!type .type ().isSimple () || type .card ().isArray () || type .type () == Types .LangAlt )
388376 {
@@ -392,16 +380,13 @@ else if (!type.type().isSimple() || type.card().isArray() || type.type() == Type
392380 type .type ().name () + "' in '" + attr .getPrefix () + ":" + attr .getLocalName () + "=" + attr .getValue ()
393381 + "' is a structured or array type, but attributes are simple types" );
394382 }
395- else
383+ // PDFBOX-6125: Default to text or skip
384+ if (attr .getValue () == null || attr .getValue ().isEmpty ())
396385 {
397- // PDFBOX-6125: Default to text or skip
398- if (attr .getValue () == null || attr .getValue ().isEmpty ())
399- {
400- schema .removeAttribute (attr .getLocalName ());
401- return ;
402- }
403- type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
386+ schema .removeAttribute (attr .getLocalName ());
387+ return ;
404388 }
389+ type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
405390 }
406391
407392 try
@@ -467,11 +452,8 @@ private void createProperty(XMPMetadata xmp, Element property, PropertyType type
467452 throw new XmpParsingException (ErrorType .InvalidType , "No type defined for {" + namespace + "}"
468453 + name );
469454 }
470- else
471- {
472- // use it as string
473- manageSimpleType (xmp , property , Types .Text , container );
474- }
455+ // use it as string
456+ manageSimpleType (xmp , property , Types .Text , container );
475457 }
476458 else if (type .type () == Types .LangAlt )
477459 {
@@ -1153,10 +1135,6 @@ private AbstractStructuredType tryParseAttributesAsProperties(
11531135 PropertiesDescription pm , QName qName ) throws XmpParsingException
11541136 {
11551137 NamedNodeMap attributes = liElement .getAttributes ();
1156- if (attributes == null )
1157- {
1158- return ast ;
1159- }
11601138 for (int i = 0 ; i < attributes .getLength (); ++i )
11611139 {
11621140 Attr attr = (Attr ) attributes .item (i );
@@ -1212,11 +1190,8 @@ else if (XmpConstants.DEFAULT_RDF_PREFIX.equals(attr.getPrefix()))
12121190 throw new XmpParsingException (ErrorType .InvalidType , "No type defined for {" + attr .getNamespaceURI () + "}"
12131191 + attr .getLocalName ());
12141192 }
1215- else
1216- {
1217- // PDFBOX-2318, PDFBOX-6106: Default to text if no type is found
1218- type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
1219- }
1193+ // PDFBOX-2318, PDFBOX-6106: Default to text if no type is found
1194+ type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
12201195 }
12211196 else if (!type .type ().isSimple () || type .card ().isArray () || type .type () == Types .LangAlt )
12221197 {
@@ -1226,15 +1201,12 @@ else if (!type.type().isSimple() || type.card().isArray() || type.type() == Type
12261201 type .type ().name () + "' in '" + attr .getPrefix () + ":" + attr .getLocalName () + "=" + attr .getValue ()
12271202 + "' is a structured or array type, but attributes are simple types" );
12281203 }
1229- else
1204+ // PDFBOX-6125: Default to text or skip
1205+ if (attr .getValue () == null || attr .getValue ().isEmpty ())
12301206 {
1231- // PDFBOX-6125: Default to text or skip
1232- if (attr .getValue () == null || attr .getValue ().isEmpty ())
1233- {
1234- continue ;
1235- }
1236- type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
1207+ continue ;
12371208 }
1209+ type = TypeMapping .createPropertyType (Types .Text , Cardinality .Simple );
12381210 }
12391211 AbstractSimpleProperty asp = tm .instanciateSimpleProperty (
12401212 attr .getNamespaceURI (), attr .getPrefix (), attr .getLocalName (),
0 commit comments