I have split out the patch I provided into two pieces.  Attached is the
piece for 605941.

-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187
diff -ur xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPArray.java xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPArray.java
--- xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPArray.java	2010-12-04 18:46:09.000000000 +0000
+++ xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPArray.java	2010-12-04 20:18:25.000000000 +0000
@@ -19,6 +19,8 @@
 
 package org.apache.xmlgraphics.xmp;
 
+import java.net.URI;
+
 import java.util.List;
 
 import org.xml.sax.ContentHandler;
@@ -216,15 +218,19 @@
         for (int i = 0, c = values.size(); i < c; i++) {
             String lang = (String)xmllang.get(i);
             atts.clear();
+            Object v = values.get(i);
             if (lang != null) {
                 atts.addAttribute(XMPConstants.XML_NS, "lang", "xml:lang", "CDATA", lang);
             }
+            if (v instanceof URI) {
+                atts.addAttribute(XMPConstants.RDF_NAMESPACE, "resource",
+                        "rdf:resource", "CDATA", ((URI)v).toString());
+            }
             handler.startElement(XMPConstants.RDF_NAMESPACE,
                     "li", "rdf:li", atts);
-            Object v = values.get(i);
             if (v instanceof XMPComplexValue) {
                 ((XMPComplexValue)v).toSAX(handler);
-            } else {
+            } else if (!(v instanceof URI)) {
                 String value = (String)values.get(i);
                 char[] chars = value.toCharArray();
                 handler.characters(chars, 0, chars.length);
diff -ur xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java
--- xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java	2010-12-04 18:46:09.000000000 +0000
+++ xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java	2010-12-04 20:35:47.000000000 +0000
@@ -19,6 +19,9 @@
 
 package org.apache.xmlgraphics.xmp;
 
+import java.net.URI;
+import java.net.URISyntaxException;
+
 import java.util.Stack;
 
 import org.xml.sax.Attributes;
@@ -227,6 +236,15 @@
                         } else {
                             getCurrentArray(true).add(s);
                         }
+                    } else {
+                        String res = atts.getValue(XMPConstants.RDF_NAMESPACE,
+                                "resource");
+                        try {
+                            URI resource = new URI(res);
+                            getCurrentArray(true).add(resource);
+                        } catch (URISyntaxException e) {
+                            throw new SAXException("rdf:resource value is not a well-formed URI", e);
+                        }
                     }
                 }
             } else if ("Description".equals(localName)) {
@@ -261,9 +279,18 @@
                 String s = content.toString().trim();
                 prop = new XMPProperty(name, s);
                 String lang = atts.getValue(XMPConstants.XML_NS, "lang");
+                String res = atts.getValue(XMPConstants.RDF_NAMESPACE, "resource");
                 if (lang != null) {
                     prop.setXMLLang(lang);
                 }
+                if (res != null) {
+                    try {
+                        URI resource = new URI(res);
+                        prop.setValue(resource);
+                    } catch (URISyntaxException e) {
+                        throw new SAXException("rdf:resource value is not a well-formed URI", e);
+                    }
+                }
             }
             if (prop.getName() == null) {
                 throw new IllegalStateException("No content in XMP property");
diff -ur xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java
--- xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java	2010-12-04 18:46:09.000000000 +0000
+++ xmlgraphics-commons.work/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java	2010-12-04 20:15:46.000000000 +0000
@@ -19,6 +19,8 @@
 
 package org.apache.xmlgraphics.xmp;
 
+import java.net.URI;
+
 import java.util.Iterator;
 import java.util.Map;
 
@@ -38,6 +40,7 @@
     private Object value;
     private String xmllang;
     private Map qualifiers;
+    private boolean uri;
 
     /**
      * Creates a new XMP property.
@@ -47,6 +50,7 @@
     public XMPProperty(QName name, Object value) {
         this.name = name;
         this.value = value;
+        this.uri = false;
     }
 
     /** @return the qualified name of the property (namespace URI + local name) */
@@ -192,12 +196,15 @@
     public void toSAX(ContentHandler handler) throws SAXException {
         AttributesImpl atts = new AttributesImpl();
         String qName = getEffectiveQName();
+        if (value instanceof URI) {
+            atts.addAttribute(XMPConstants.RDF_NAMESPACE, "resource", "rdf:resource", "CDATA", ((URI)value).toString());
+        }
         handler.startElement(getName().getNamespaceURI(),
                 getName().getLocalName(), qName, atts);
         if (value instanceof XMPComplexValue) {
             XMPComplexValue cv = ((XMPComplexValue)value);
             cv.toSAX(handler);
-        } else {
+        } else if (!(value instanceof URI)) {
             char[] chars = value.toString().toCharArray();
             handler.characters(chars, 0, chars.length);
         }

Attachment: signature.asc
Description: Digital signature

Reply via email to