You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by jg...@apache.org on 2025/02/14 20:58:26 UTC

(xmlgraphics-commons) branch jgoncalves-pdfa-extension-fix updated (d2e2510 -> 80a1b52)

This is an automated email from the ASF dual-hosted git repository.

jgoncalves pushed a change to branch jgoncalves-pdfa-extension-fix
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-commons.git


 discard d2e2510  FOP-3236: Add all the needed namespaces to the parent element
     new 80a1b52  FOP-3236: Add all the needed namespaces to the parent element

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d2e2510)
            \
             N -- N -- N   refs/heads/jgoncalves-pdfa-extension-fix (80a1b52)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/apache/xmlgraphics/xmp/Metadata.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


(xmlgraphics-commons) 01/01: FOP-3236: Add all the needed namespaces to the parent element

Posted by jg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jgoncalves pushed a commit to branch jgoncalves-pdfa-extension-fix
in repository https://gitbox.apache.org/repos/asf/xmlgraphics-commons.git

commit 80a1b521e3a50921c5fb99451aa3421a7b4da62e
Author: Joao Goncalves <jg...@smartcommunications.com>
AuthorDate: Thu Feb 13 17:12:52 2025 -0600

    FOP-3236: Add all the needed namespaces to the parent element
---
 src/main/java/org/apache/xmlgraphics/xmp/Metadata.java      | 13 +++++++++++++
 src/main/java/org/apache/xmlgraphics/xmp/XMPSchema.java     | 13 +++++++++++++
 .../xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchema.java |  3 +++
 src/test/java/org/apache/xmlgraphics/xmp/XMPArrayTest.java  |  4 ++++
 .../java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java    |  2 ++
 .../xmp/schemas/pdf/PDFAExtensionAdapterTest.java           |  4 ++--
 .../xmp/schemas/pdf/PDFAExtensionXMPSchemaTest.java         | 11 +++++++++++
 7 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/src/main/java/org/apache/xmlgraphics/xmp/Metadata.java b/src/main/java/org/apache/xmlgraphics/xmp/Metadata.java
index 5f8a44e..cc24896 100644
--- a/src/main/java/org/apache/xmlgraphics/xmp/Metadata.java
+++ b/src/main/java/org/apache/xmlgraphics/xmp/Metadata.java
@@ -134,6 +134,13 @@ public class Metadata implements XMLizable, PropertyAccess {
                         if (prefix != null) {
                             handler.startPrefixMapping(prefix, ns);
                         }
+
+                        if (schema != null) {
+                            for (Map.Entry<String, String> entry : schema.getExtraNamespaces().entrySet()) {
+                                handler.startPrefixMapping(entry.getKey(), entry.getValue());
+                            }
+                        }
+
                         handler.startElement(XMPConstants.RDF_NAMESPACE,
                                 "Description", "rdf:Description", atts);
                         empty = false;
@@ -147,6 +154,12 @@ public class Metadata implements XMLizable, PropertyAccess {
                 if (prefix != null) {
                     handler.endPrefixMapping(prefix);
                 }
+
+                if (schema != null) {
+                    for (String extraPrefix : schema.getExtraNamespaces().keySet()) {
+                        handler.endPrefixMapping(extraPrefix);
+                    }
+                }
             }
         }
 
diff --git a/src/main/java/org/apache/xmlgraphics/xmp/XMPSchema.java b/src/main/java/org/apache/xmlgraphics/xmp/XMPSchema.java
index 0eb414e..be94579 100644
--- a/src/main/java/org/apache/xmlgraphics/xmp/XMPSchema.java
+++ b/src/main/java/org/apache/xmlgraphics/xmp/XMPSchema.java
@@ -19,6 +19,9 @@
 
 package org.apache.xmlgraphics.xmp;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.xmlgraphics.util.QName;
 import org.apache.xmlgraphics.xmp.merge.MergeRuleSet;
 
@@ -31,6 +34,7 @@ public class XMPSchema {
 
     private String namespace;
     private String prefix;
+    private Map<String, String> extraNamespaces = new HashMap<>();
 
     /**
      * Constructs a new XMP schema object.
@@ -65,4 +69,13 @@ public class XMPSchema {
     public MergeRuleSet getDefaultMergeRuleSet() {
         return defaultMergeRuleSet;
     }
+
+    /** Returns the map of extra namespaces to by used by child properties */
+    public Map<String, String> getExtraNamespaces() {
+        return extraNamespaces;
+    }
+
+    public void addExtraNamespace(String prefix, String namespace) {
+        this.extraNamespaces.put(prefix, namespace);
+    }
 }
diff --git a/src/main/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchema.java b/src/main/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchema.java
index 70e97f6..d4d119f 100644
--- a/src/main/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchema.java
+++ b/src/main/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchema.java
@@ -31,6 +31,9 @@ public class PDFAExtensionXMPSchema extends XMPSchema {
     /** Creates a new schema instance for Dublin Core. */
     public PDFAExtensionXMPSchema() {
         super(XMPConstants.PDF_A_EXTENSION, "pdfaExtension");
+
+        addExtraNamespace("pdfaSchema", XMPConstants.PDF_A_SCHEMA);
+        addExtraNamespace("pdfaProperty", XMPConstants.PDF_A_PROPERTY);
     }
 
     /**
diff --git a/src/test/java/org/apache/xmlgraphics/xmp/XMPArrayTest.java b/src/test/java/org/apache/xmlgraphics/xmp/XMPArrayTest.java
index c6e8300..3dea116 100644
--- a/src/test/java/org/apache/xmlgraphics/xmp/XMPArrayTest.java
+++ b/src/test/java/org/apache/xmlgraphics/xmp/XMPArrayTest.java
@@ -45,6 +45,8 @@ public class XMPArrayTest {
                 + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n"
                 + "<rdf:RDF>\n"
                 + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n"
+                + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n"
+                + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n"
                 + "<rdf:Description rdf:about=\"\">\n"
                 + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n"
                 + "<rdf:Bag>\n"
@@ -86,6 +88,8 @@ public class XMPArrayTest {
                 + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n"
                 + "<rdf:RDF>\n"
                 + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n"
+                + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n"
+                + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n"
                 + "<rdf:Description rdf:about=\"\">\n"
                 + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n"
                 + "<rdf:Bag>\n"
diff --git a/src/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java b/src/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
index 3191b63..47e60e0 100644
--- a/src/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
+++ b/src/test/java/org/apache/xmlgraphics/xmp/XMPPropertyTest.java
@@ -39,6 +39,8 @@ public class XMPPropertyTest {
                 + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n"
                 + "<rdf:RDF>\n"
                 + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n"
+                + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n"
+                + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n"
                 + "<rdf:Description rdf:about=\"\">\n"
                 + "<xmlns:http://www.aiim.org/pdfa/ns/property#>\n"
                 + "<prefix1:name1>\n"
diff --git a/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionAdapterTest.java b/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionAdapterTest.java
index eedf9e2..a9435a6 100644
--- a/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionAdapterTest.java
+++ b/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionAdapterTest.java
@@ -41,12 +41,13 @@ public class PDFAExtensionAdapterTest {
                 + "rdf:http://www.w3.org/1999/02/22-rdf-syntax-ns#\n"
                 + "<rdf:RDF>\n"
                 + "pdfaExtension:http://www.aiim.org/pdfa/ns/extension/\n"
+                + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n"
+                + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n"
                 + "<rdf:Description rdf:about=\"\">\n"
                 + "<pdfaExtension:schemas>\n"
                 + "<rdf:Bag>\n"
                 + "<rdf:li rdf:parseType=\"Resource\">\n"
                 + "<pdfaSchema:schema>\n"
-                + "pdfaSchema:http://www.aiim.org/pdfa/ns/schema#\n"
                 + "PDF/UA identification schema\n"
                 + "</pdfaSchema:schema>\n"
                 + "<pdfaSchema:namespaceURI>\n"
@@ -59,7 +60,6 @@ public class PDFAExtensionAdapterTest {
                 + "<rdf:Seq>\n"
                 + "<rdf:li rdf:parseType=\"Resource\">\n"
                 + "<pdfaProperty:name>\n"
-                + "pdfaProperty:http://www.aiim.org/pdfa/ns/property#\n"
                 + "part\n"
                 + "</pdfaProperty:name>\n"
                 + "<pdfaProperty:valueType>\n"
diff --git a/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchemaTest.java b/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchemaTest.java
index b007eae..c7253df 100644
--- a/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchemaTest.java
+++ b/src/test/java/org/apache/xmlgraphics/xmp/schemas/pdf/PDFAExtensionXMPSchemaTest.java
@@ -22,6 +22,8 @@ package org.apache.xmlgraphics.xmp.schemas.pdf;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 import org.apache.xmlgraphics.xmp.XMPConstants;
 
@@ -33,6 +35,15 @@ public class PDFAExtensionXMPSchemaTest {
 
         assertEquals("pdfaExtension", schema.getPreferredPrefix());
         assertEquals(XMPConstants.PDF_A_EXTENSION, schema.getNamespace());
+        assertFalse("Must have the namespaces of child properties", schema.getExtraNamespaces().isEmpty());
 
+        assertTrue("The prefix must be the key", schema.getExtraNamespaces().containsKey("pdfaSchema"));
+        assertTrue("The prefix must be the key", schema.getExtraNamespaces().containsKey("pdfaProperty"));
+
+
+        assertEquals("Namespace must match the correct prefix`", XMPConstants.PDF_A_SCHEMA,
+                schema.getExtraNamespaces().get("pdfaSchema"));
+        assertEquals("Namespace must match the correct prefix`", XMPConstants.PDF_A_PROPERTY,
+                schema.getExtraNamespaces().get("pdfaProperty"));
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org