View | Details | Raw Unified | Return to bug 50497
Collapse All | Expand All

(-)xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPArray.java (-2 / +8 lines)
Lines 19-24 Link Here
19
19
20
package org.apache.xmlgraphics.xmp;
20
package org.apache.xmlgraphics.xmp;
21
21
22
import java.net.URI;
23
22
import java.util.List;
24
import java.util.List;
23
25
24
import org.xml.sax.ContentHandler;
26
import org.xml.sax.ContentHandler;
Lines 216-230 Link Here
216
        for (int i = 0, c = values.size(); i < c; i++) {
218
        for (int i = 0, c = values.size(); i < c; i++) {
217
            String lang = (String)xmllang.get(i);
219
            String lang = (String)xmllang.get(i);
218
            atts.clear();
220
            atts.clear();
221
            Object v = values.get(i);
219
            if (lang != null) {
222
            if (lang != null) {
220
                atts.addAttribute(XMPConstants.XML_NS, "lang", "xml:lang", "CDATA", lang);
223
                atts.addAttribute(XMPConstants.XML_NS, "lang", "xml:lang", "CDATA", lang);
221
            }
224
            }
225
            if (v instanceof URI) {
226
                atts.addAttribute(XMPConstants.RDF_NAMESPACE, "resource",
227
                        "rdf:resource", "CDATA", ((URI)v).toString());
228
            }
222
            handler.startElement(XMPConstants.RDF_NAMESPACE,
229
            handler.startElement(XMPConstants.RDF_NAMESPACE,
223
                    "li", "rdf:li", atts);
230
                    "li", "rdf:li", atts);
224
            Object v = values.get(i);
225
            if (v instanceof XMPComplexValue) {
231
            if (v instanceof XMPComplexValue) {
226
                ((XMPComplexValue)v).toSAX(handler);
232
                ((XMPComplexValue)v).toSAX(handler);
227
            } else {
233
            } else if (!(v instanceof URI)) {
228
                String value = (String)values.get(i);
234
                String value = (String)values.get(i);
229
                char[] chars = value.toCharArray();
235
                char[] chars = value.toCharArray();
230
                handler.characters(chars, 0, chars.length);
236
                handler.characters(chars, 0, chars.length);
(-)xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPHandler.java (+21 lines)
Lines 19-24 Link Here
19
19
20
package org.apache.xmlgraphics.xmp;
20
package org.apache.xmlgraphics.xmp;
21
21
22
import java.net.URI;
23
import java.net.URISyntaxException;
24
22
import java.util.Stack;
25
import java.util.Stack;
23
26
24
import org.xml.sax.Attributes;
27
import org.xml.sax.Attributes;
Lines 227-232 Link Here
227
                        } else {
236
                        } else {
228
                            getCurrentArray(true).add(s);
237
                            getCurrentArray(true).add(s);
229
                        }
238
                        }
239
                    } else {
240
                        String res = atts.getValue(XMPConstants.RDF_NAMESPACE,
241
                                "resource");
242
                        try {
243
                            URI resource = new URI(res);
244
                            getCurrentArray(true).add(resource);
245
                        } catch (URISyntaxException e) {
246
                            throw new SAXException("rdf:resource value is not a well-formed URI", e);
247
                        }
230
                    }
248
                    }
231
                }
249
                }
232
            } else if ("Description".equals(localName)) {
250
            } else if ("Description".equals(localName)) {
Lines 261-269 Link Here
261
                String s = content.toString().trim();
279
                String s = content.toString().trim();
262
                prop = new XMPProperty(name, s);
280
                prop = new XMPProperty(name, s);
263
                String lang = atts.getValue(XMPConstants.XML_NS, "lang");
281
                String lang = atts.getValue(XMPConstants.XML_NS, "lang");
282
                String res = atts.getValue(XMPConstants.RDF_NAMESPACE, "resource");
264
                if (lang != null) {
283
                if (lang != null) {
265
                    prop.setXMLLang(lang);
284
                    prop.setXMLLang(lang);
266
                }
285
                }
286
                if (res != null) {
287
                    try {
288
                        URI resource = new URI(res);
289
                        prop.setValue(resource);
290
                    } catch (URISyntaxException e) {
291
                        throw new SAXException("rdf:resource value is not a well-formed URI", e);
292
                    }
293
                }
267
            }
294
            }
268
            if (prop.getName() == null) {
295
            if (prop.getName() == null) {
269
                throw new IllegalStateException("No content in XMP property");
296
                throw new IllegalStateException("No content in XMP property");
(-)xmlgraphics-commons.old/src/java/org/apache/xmlgraphics/xmp/XMPProperty.java (-1 / +8 lines)
Lines 19-24 Link Here
19
19
20
package org.apache.xmlgraphics.xmp;
20
package org.apache.xmlgraphics.xmp;
21
21
22
import java.net.URI;
23
22
import java.util.Iterator;
24
import java.util.Iterator;
23
import java.util.Map;
25
import java.util.Map;
24
26
Lines 38-43 Link Here
38
    private Object value;
40
    private Object value;
39
    private String xmllang;
41
    private String xmllang;
40
    private Map qualifiers;
42
    private Map qualifiers;
43
    private boolean uri;
41
44
42
    /**
45
    /**
43
     * Creates a new XMP property.
46
     * Creates a new XMP property.
Lines 47-52 Link Here
47
    public XMPProperty(QName name, Object value) {
50
    public XMPProperty(QName name, Object value) {
48
        this.name = name;
51
        this.name = name;
49
        this.value = value;
52
        this.value = value;
53
        this.uri = false;
50
    }
54
    }
51
55
52
    /** @return the qualified name of the property (namespace URI + local name) */
56
    /** @return the qualified name of the property (namespace URI + local name) */
Lines 192-203 Link Here
192
    public void toSAX(ContentHandler handler) throws SAXException {
196
    public void toSAX(ContentHandler handler) throws SAXException {
193
        AttributesImpl atts = new AttributesImpl();
197
        AttributesImpl atts = new AttributesImpl();
194
        String qName = getEffectiveQName();
198
        String qName = getEffectiveQName();
199
        if (value instanceof URI) {
200
            atts.addAttribute(XMPConstants.RDF_NAMESPACE, "resource", "rdf:resource", "CDATA", ((URI)value).toString());
201
        }
195
        handler.startElement(getName().getNamespaceURI(),
202
        handler.startElement(getName().getNamespaceURI(),
196
                getName().getLocalName(), qName, atts);
203
                getName().getLocalName(), qName, atts);
197
        if (value instanceof XMPComplexValue) {
204
        if (value instanceof XMPComplexValue) {
198
            XMPComplexValue cv = ((XMPComplexValue)value);
205
            XMPComplexValue cv = ((XMPComplexValue)value);
199
            cv.toSAX(handler);
206
            cv.toSAX(handler);
200
        } else {
207
        } else if (!(value instanceof URI)) {
201
            char[] chars = value.toString().toCharArray();
208
            char[] chars = value.toString().toCharArray();
202
            handler.characters(chars, 0, chars.length);
209
            handler.characters(chars, 0, chars.length);
203
        }
210
        }

Return to bug 50497