You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ms...@apache.org on 2015/07/21 18:53:55 UTC
svn commit: r1692171 -
/pdfbox/trunk/xmpbox/src/main/java/org/apache/xmpbox/xml/XmpSerializer.java
Author: msahyoun
Date: Tue Jul 21 16:53:54 2015
New Revision: 1692171
URL: http://svn.apache.org/r1692171
Log:
PDFBOX-2896: set ArrayType contents prefix to rdf
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=1692171&r1=1692170&r2=1692171&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 Tue Jul 21 16:53:54 2015
@@ -95,12 +95,12 @@ public class XmpSerializer
fillElementWithAttributes(selem, schema);
// the content
List<AbstractField> fields = schema.getAllProperties();
- serializeFields(doc, selem, fields,schema.getPrefix(), true);
+ serializeFields(doc, selem, fields,schema.getPrefix(), null, true);
// return created schema
return selem;
}
- public void serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, boolean wrapWithProperty)
+ public void serializeFields(Document doc, Element parent, List<AbstractField> fields, String resourceNS, String prefix, boolean wrapWithProperty)
{
for (AbstractField field : fields)
{
@@ -108,7 +108,19 @@ public class XmpSerializer
if (field instanceof AbstractSimpleProperty)
{
AbstractSimpleProperty simple = (AbstractSimpleProperty) field;
- Element esimple = doc.createElement(simple.getPrefix() + ":" + simple.getPropertyName());
+
+ String localPrefix;
+
+ if (prefix != null && !prefix.isEmpty())
+ {
+ localPrefix = prefix;
+ }
+ else
+ {
+ localPrefix = simple.getPrefix();
+ }
+
+ Element esimple = doc.createElement(localPrefix + ":" + simple.getPropertyName());
esimple.setTextContent(simple.getStringValue());
List<Attribute> attributes = simple.getAllAttributes();
for (Attribute attribute : attributes)
@@ -130,7 +142,7 @@ public class XmpSerializer
asimple.appendChild(econtainer);
// for each element of the array
List<AbstractField> innerFields = array.getAllProperties();
- serializeFields(doc, econtainer, innerFields,resourceNS, false);
+ serializeFields(doc, econtainer, innerFields,resourceNS, XmpConstants.DEFAULT_RDF_PREFIX, false);
}
else if (field instanceof AbstractStructuredType)
{
@@ -153,7 +165,7 @@ public class XmpSerializer
{
estructured.setAttribute("rdf:parseType", "Resource");
// all properties
- serializeFields(doc, estructured, innerFields,resourceNS, true);
+ serializeFields(doc, estructured, innerFields,resourceNS, null, true);
}
else
{
@@ -161,7 +173,7 @@ public class XmpSerializer
Element econtainer = doc.createElement(XmpConstants.DEFAULT_RDF_PREFIX + ":" + "Description");
estructured.appendChild(econtainer);
// all properties
- serializeFields(doc, econtainer, innerFields,resourceNS, true);
+ serializeFields(doc, econtainer, innerFields,resourceNS, null, true);
}
}
else