Author: tilman
Date: Fri Jun 27 20:07:30 2025
New Revision: 1926774

URL: http://svn.apache.org/viewvc?rev=1926774&view=rev
Log:
PDFBOX-6027: second setAttributeNS() parameter must be "xml:lang" instead of 
"lang" to avoid troubles if Apache Xalan is in the classpath

Modified:
    pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java

Modified: 
pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java?rev=1926774&r1=1926773&r2=1926774&view=diff
==============================================================================
--- pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java 
(original)
+++ pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java 
Fri Jun 27 20:07:30 2025
@@ -140,7 +140,22 @@ public class XmpSerializer
                 List<Attribute> attributes = simple.getAllAttributes();
                 for (Attribute attribute : attributes)
                 {
-                    esimple.setAttributeNS(attribute.getNamespace(), 
attribute.getName(), attribute.getValue());
+                    String name = attribute.getName();
+                    // we must add "xml:" to the qualifiedName parameter or it 
won't appear in the result
+                    // If a more strict transformer like Apache Xalan is in 
the classpath (e.g. PDFBOX-4817)
+                    if 
(XMLConstants.XML_NS_URI.equals(attribute.getNamespace()) && 
+                        name != null && !name.contains(":"))
+                    {
+                        esimple.setAttributeNS(XMLConstants.XML_NS_URI,
+                                               XMLConstants.XML_NS_PREFIX + 
":" + name,
+                                               attribute.getValue());
+                    }
+                    else
+                    {
+                        esimple.setAttributeNS(attribute.getNamespace(),
+                                               name,
+                                               attribute.getValue());
+                    }
                 }
                 parent.appendChild(esimple);
             }


Reply via email to