You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2025/06/27 20:07:22 UTC
svn commit: r1926772 - /pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
Author: tilman
Date: Fri Jun 27 20:07:22 2025
New Revision: 1926772
URL: http://svn.apache.org/viewvc?rev=1926772&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/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
Modified: pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java?rev=1926772&r1=1926771&r2=1926772&view=diff
==============================================================================
--- pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java (original)
+++ pdfbox/branches/3.0/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java Fri Jun 27 20:07:22 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);
}