Author: tilman
Date: Wed Dec 24 11:15:04 2025
New Revision: 1930830

Log:
PDFBOX-6131: allow first char lower case in "pdfaProperty:valueType" for 
extension schemas + test

Modified:
   
pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/PdfaExtensionHelper.java
   
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java

Modified: 
pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/PdfaExtensionHelper.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/PdfaExtensionHelper.java
     Wed Dec 24 11:14:59 2025        (r1930829)
+++ 
pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/PdfaExtensionHelper.java
     Wed Dec 24 11:15:04 2025        (r1930830)
@@ -52,8 +52,10 @@ public final class PdfaExtensionHelper
 {
 
     public static final String CLOSED_CHOICE = "closed Choice of ";
+    public static final String CLOSED_CHOICE_U = "Closed Choice of ";
 
     public static final String OPEN_CHOICE = "open Choice of ";
+    public static final String OPEN_CHOICE_U = "Open Choice of ";
 
     private PdfaExtensionHelper()
     {
@@ -275,11 +277,11 @@ public final class PdfaExtensionHelper
             return TypeMapping.createPropertyType(Types.LangAlt, 
Cardinality.Simple);
         }
         // else all other cases
-        if (valueType.startsWith(CLOSED_CHOICE))
+        if (valueType.startsWith(CLOSED_CHOICE) || 
valueType.startsWith(CLOSED_CHOICE_U))
         {
             valueType = valueType.substring(CLOSED_CHOICE.length());
         }
-        else if (valueType.startsWith(OPEN_CHOICE))
+        else if (valueType.startsWith(OPEN_CHOICE) || 
valueType.startsWith(OPEN_CHOICE_U))
         {
             valueType = valueType.substring(OPEN_CHOICE.length());
         }
@@ -287,7 +289,7 @@ public final class PdfaExtensionHelper
         Cardinality card = Cardinality.Simple;
         if (pos > 0)
         {
-            String scard = valueType.substring(0, pos);
+            String scard = valueType.substring(0, pos).toLowerCase();
             switch (scard)
             {
                 case "seq":

Modified: 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java
==============================================================================
--- 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java
        Wed Dec 24 11:14:59 2025        (r1930829)
+++ 
pdfbox/branches/3.0/xmpbox/src/test/java/org/apache/xmpbox/xml/DomXmpParserTest.java
        Wed Dec 24 11:15:04 2025        (r1930830)
@@ -1400,4 +1400,17 @@ class DomXmpParserTest
                 () -> xmpParser1.parse(s.getBytes(StandardCharsets.UTF_8)));
         assertEquals("Failed to instantiate DateType property with value 
2019-05-02T22:03:5Z in xmp:CreateDate", ex.getMessage());
     }
+
+    @Test
+    void testPDFBox6131() throws IOException, XmpParsingException, 
BadFieldValueException
+    {
+        // Contains "Open Choice of Integer" instead of "open Choice of 
Integer"
+        try (InputStream is = 
DomXmpParser.class.getResourceAsStream("/org/apache/xmpbox/xml/PDFBOX-6131-0015675.xml"))
+        {
+            DomXmpParser xmpParser = new DomXmpParser();
+            XMPMetadata xmp = xmpParser.parse(is);
+            XMPSchema uaSchema2  = 
xmp.getSchema("http://www.aiim.org/pdfua/ns/id/";);
+            assertEquals(1, uaSchema2.getIntegerPropertyValueAsSimple("part"));
+        }
+    }
 }

Reply via email to