Debian Codegraph @

src/com/adobe/internal/xmp/impl/XMPNormalizer.java

raw symbols SCIP
1 // =================================================================================================
2 // ADOBE SYSTEMS INCORPORATED
3 // Copyright 2006 Adobe Systems Incorporated
4 // All Rights Reserved
5 //
6 // NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms
7 // of the Adobe license agreement accompanying it.
8 // =================================================================================================
9
10 package com.adobe.internal.xmp.impl;
11
12 import java.util.ArrayList;
13 import java.util.Calendar;
14 import java.util.HashMap;
15 import java.util.Iterator;
16 import java.util.List;
17 import java.util.Map;
18
19 import com.adobe.internal.xmp.XMPConst;
20 import com.adobe.internal.xmp.XMPDateTime;
21 import com.adobe.internal.xmp.XMPError;
22 import com.adobe.internal.xmp.XMPException;
23 import com.adobe.internal.xmp.XMPMeta;
24 import com.adobe.internal.xmp.XMPMetaFactory;
25 import com.adobe.internal.xmp.XMPUtils;
26 import com.adobe.internal.xmp.impl.xpath.XMPPath;
27 import com.adobe.internal.xmp.impl.xpath.XMPPathParser;
28 import com.adobe.internal.xmp.options.ParseOptions;
29 import com.adobe.internal.xmp.options.PropertyOptions;
30 import com.adobe.internal.xmp.properties.XMPAliasInfo;
31
32 /**
33 * @author Stefan Makswit
34 * @version $Revision$
35 * @since Aug 18, 2006
36 */
37 public class XMPNormalizer
38 {
39 /** caches the correct dc-property array forms */
40 private static Map dcArrayForms;
41 /** init char tables */
42 static
43 {
44 initDCArrays();
45 }
46
47
48 /**
49 * Hidden constructor
50 */
51 private XMPNormalizer()
52 {
53 // EMPTY
54 }
55
56
57 /**
58 * Normalizes a raw parsed XMPMeta-Object
59 * @param xmp the raw metadata object
60 * @param options the parsing options
61 * @return Returns the normalized metadata object
62 * @throws XMPException Collects all severe processing errors.
63 */
64 static XMPMeta process(XMPMetaImpl xmp, ParseOptions options) throws XMPException
65 {
66 XMPNode tree = xmp.getRoot();
67
68 touchUpDataModel(xmp);
69
70 // FfF: collect the aliases to prevent browsing the tree again
71 moveExplicitAliases(tree, options);
72
73 tweakOldXMP(tree);
74
75 deleteEmptySchemas(tree);
76
77 return xmp;
78 }
79
80
81 /**
82 * Tweak old XMP: Move an instance ID from rdf:about to the
83 * <em>xmpMM:InstanceID</em> property. An old instance ID usually looks
84 * like &quot;uuid:bac965c4-9d87-11d9-9a30-000d936b79c4&quot;, plus InDesign
85 * 3.0 wrote them like &quot;bac965c4-9d87-11d9-9a30-000d936b79c4&quot;. If
86 * the name looks like a UUID simply move it to <em>xmpMM:InstanceID</em>,
87 * don't worry about any existing <em>xmpMM:InstanceID</em>. Both will
88 * only be present when a newer file with the <em>xmpMM:InstanceID</em>
89 * property is updated by an old app that uses <em>rdf:about</em>.
90 *
91 * @param tree the root of the metadata tree
92 * @throws XMPException Thrown if tweaking fails.
93 */
94 private static void tweakOldXMP(XMPNode tree) throws XMPException
95 {
96 if (tree.getName() != null && tree.getName().length() >= Utils.UUID_LENGTH)
97 {
98 String nameStr = tree.getName().toLowerCase();
99 if (nameStr.startsWith("uuid:"))
100 {
101 nameStr = nameStr.substring(5);
102 }
103
104 if (Utils.checkUUIDFormat(nameStr))
105 {
106 // move UUID to xmpMM:InstanceID and remove it from the root node
107 XMPPath path = XMPPathParser.expandXPath(XMPConst.NS_XMP_MM, "InstanceID");
108 XMPNode idNode = XMPNodeUtils.findNode (tree, path, true, null);
109 if (idNode != null)
110 {
111 idNode.setOptions(null); // Clobber any existing xmpMM:InstanceID.
112 idNode.setValue("uuid:" + nameStr);
113 idNode.removeChildren();
114 idNode.removeQualifiers();
115 tree.setName(null);
116 }
117 else
118 {
119 throw new XMPException("Failure creating xmpMM:InstanceID",
120 XMPError.INTERNALFAILURE);
121 }
122 }
123 }
124 }
125
126
127 /**
128 * Visit all schemas to do general fixes and handle special cases.
129 *
130 * @param xmp the metadata object implementation
131 * @throws XMPException Thrown if the normalisation fails.
132 */
133 private static void touchUpDataModel(XMPMetaImpl xmp) throws XMPException
134 {
135 // make sure the DC schema is existing, because it might be needed within the normalization
136 // if not touched it will be removed by removeEmptySchemas
137 XMPNodeUtils.findSchemaNode(xmp.getRoot(), XMPConst.NS_DC, true);
138
139 // Do the special case fixes within each schema.
140 for (Iterator it = xmp.getRoot().iterateChildren(); it.hasNext();)
141 {
142 XMPNode currSchema = (XMPNode) it.next();
143 if (XMPConst.NS_DC.equals(currSchema.getName()))
144 {
145 normalizeDCArrays(currSchema);
146 }
147 else if (XMPConst.NS_EXIF.equals(currSchema.getName()))
148 {
149 // Do a special case fix for exif:GPSTimeStamp.
150 fixGPSTimeStamp(currSchema);
151 XMPNode userComment = XMPNodeUtils.findChildNode(currSchema, "exif:UserComment",
152 false);
153 if (userComment != null)
154 {
155 if(userComment.getOptions().isSimple()){
156 XMPNode newNode = new XMPNode(XMPConst.ARRAY_ITEM_NAME, userComment.getValue(),
157 userComment.getOptions());
158 newNode.setParent(userComment);
159
160 int QualNo = userComment.getQualifierLength();
161 while(QualNo > 0){
162 newNode.addQualifier(userComment.getQualifier(userComment.getQualifierLength() - QualNo));
163 --QualNo;
164 }
165
166 userComment.removeQualifiers();
167 if ( ! newNode.getOptions().getHasLanguage() ) {
168 XMPNode langQual = new XMPNode ( "xml:lang", "x-default", new PropertyOptions().setQualifier(true) );
169 newNode.addQualifier( langQual );
170 newNode.getOptions().setHasQualifiers(true);
171 newNode.getOptions().setHasLanguage(true);
172 }
173 userComment.addChild(newNode);
174 userComment.setOptions(new PropertyOptions(PropertyOptions.ARRAY | PropertyOptions.ARRAY_ORDERED
175 |PropertyOptions.ARRAY_ALT_TEXT | PropertyOptions.ARRAY_ALTERNATE));
176 userComment.setValue("");
177
178
179 }
180 repairAltText(userComment);
181 }
182 }
183 else if (XMPConst.NS_DM.equals(currSchema.getName()))
184 {
185 // Do a special case migration of xmpDM:copyright to
186 // dc:rights['x-default'].
187 XMPNode dmCopyright = XMPNodeUtils.findChildNode(currSchema, "xmpDM:copyright",
188 false);
189 if (dmCopyright != null)
190 {
191 migrateAudioCopyright(xmp, dmCopyright);
192 }
193 }
194 else if (XMPConst.NS_XMP_RIGHTS.equals(currSchema.getName()))
195 {
196 XMPNode arrayNode = XMPNodeUtils.findChildNode(currSchema, "xmpRights:UsageTerms",
197 false);
198 if (arrayNode != null)
199 {
200 repairAltText(arrayNode);
201 }
202 }
203 }
204 }
205
206
207 /**
208 * Undo the denormalization performed by the XMP used in Acrobat 5.<br>
209 * If a Dublin Core array had only one item, it was serialized as a simple
210 * property. <br>
211 * The <code>xml:lang</code> attribute was dropped from an
212 * <code>alt-text</code> item if the language was <code>x-default</code>.
213 *
214 * @param dcSchema the DC schema node
215 * @throws XMPException Thrown if normalization fails
216 */
217 private static void normalizeDCArrays(XMPNode dcSchema) throws XMPException
218 {
219 for (int i = 1; i <= dcSchema.getChildrenLength(); i++)
220 {
221 XMPNode currProp = dcSchema.getChild(i);
222
223 PropertyOptions arrayForm = (PropertyOptions) dcArrayForms.get(currProp.getName());
224 if (arrayForm == null)
225 {
226 continue;
227 }
228 else if (currProp.getOptions().isSimple())
229 {
230 // create a new array and add the current property as child,
231 // if it was formerly simple
232 XMPNode newArray = new XMPNode(currProp.getName(), arrayForm);
233 currProp.setName(XMPConst.ARRAY_ITEM_NAME);
234 newArray.addChild(currProp);
235 dcSchema.replaceChild(i, newArray);
236
237 // fix language alternatives
238 if (arrayForm.isArrayAltText() && !currProp.getOptions().getHasLanguage())
239 {
240 XMPNode newLang = new XMPNode(XMPConst.XML_LANG, XMPConst.X_DEFAULT, null);
241 currProp.addQualifier(newLang);
242 }
243 }
244 else
245 {
246 // clear array options and add corrected array form if it has been an array before
247 currProp.getOptions().setOption(
248 PropertyOptions.ARRAY |
249 PropertyOptions.ARRAY_ORDERED |
250 PropertyOptions.ARRAY_ALTERNATE |
251 PropertyOptions.ARRAY_ALT_TEXT,
252 false);
253 currProp.getOptions().mergeWith(arrayForm);
254
255 if (arrayForm.isArrayAltText())
256 {
257 // applying for "dc:description", "dc:rights", "dc:title"
258 repairAltText(currProp);
259 }
260 }
261
262 }
263 }
264
265
266 /**
267 * Make sure that the array is well-formed AltText. Each item must be simple
268 * and have an "xml:lang" qualifier. If repairs are needed, keep simple
269 * non-empty items by adding the "xml:lang" with value "x-repair".
270 * @param arrayNode the property node of the array to repair.
271 * @throws XMPException Forwards unexpected exceptions.
272 */
273 private static void repairAltText(XMPNode arrayNode) throws XMPException
274 {
275 if (arrayNode == null ||
276 !arrayNode.getOptions().isArray())
277 {
278 // Already OK or not even an array.
279 return;
280 }
281
282 // fix options
283 arrayNode.getOptions().setArrayOrdered(true).setArrayAlternate(true).setArrayAltText(true);
284
285 for (Iterator it = arrayNode.iterateChildren(); it.hasNext();)
286 {
287 XMPNode currChild = (XMPNode) it.next();
288 if (currChild.getOptions().isCompositeProperty())
289 {
290 // Delete non-simple children.
291 it.remove();
292 }
293 else if (!currChild.getOptions().getHasLanguage())
294 {
295 String childValue = currChild.getValue();
296 if (childValue == null || childValue.length() == 0)
297 {
298 // Delete empty valued children that have no xml:lang.
299 it.remove();
300 }
301 else
302 {
303 // Add an xml:lang qualifier with the value "x-repair".
304 XMPNode repairLang = new XMPNode(XMPConst.XML_LANG, "x-repair", null);
305 currChild.addQualifier(repairLang);
306 }
307 }
308 }
309 }
310
311
312 /**
313 * Visit all of the top level nodes looking for aliases. If there is
314 * no base, transplant the alias subtree. If there is a base and strict
315 * aliasing is on, make sure the alias and base subtrees match.
316 *
317 * @param tree the root of the metadata tree
318 * @param options th parsing options
319 * @throws XMPException Forwards XMP errors
320 */
321 private static void moveExplicitAliases(XMPNode tree, ParseOptions options)
322 throws XMPException
323 {
324 if (!tree.getHasAliases())
325 {
326 return;
327 }
328 tree.setHasAliases(false);
329
330 boolean strictAliasing = options.getStrictAliasing();
331
332 for (Iterator schemaIt = tree.getUnmodifiableChildren().iterator(); schemaIt.hasNext();)
333 {
334 XMPNode currSchema = (XMPNode) schemaIt.next();
335 if (!currSchema.getHasAliases())
336 {
337 continue;
338 }
339
340 for (Iterator propertyIt = currSchema.iterateChildren(); propertyIt.hasNext();)
341 {
342 XMPNode currProp = (XMPNode) propertyIt.next();
343
344 if (!currProp.isAlias())
345 {
346 continue;
347 }
348
349 currProp.setAlias(false);
350
351 // Find the base path, look for the base schema and root node.
352 XMPAliasInfo info = XMPMetaFactory.getSchemaRegistry()
353 .findAlias(currProp.getName());
354 if (info != null)
355 {
356 // find or create schema
357 XMPNode baseSchema = XMPNodeUtils.findSchemaNode(tree, info
358 .getNamespace(), null, true);
359 baseSchema.setImplicit(false);
360
361 XMPNode baseNode = XMPNodeUtils
362 .findChildNode(baseSchema,
363 info.getPrefix() + info.getPropName(), false);
364 if (baseNode == null)
365 {
366 if (info.getAliasForm().isSimple())
367 {
368 // A top-to-top alias, transplant the property.
369 // change the alias property name to the base name
370 String qname = info.getPrefix() + info.getPropName();
371 currProp.setName(qname);
372 baseSchema.addChild(currProp);
373 // remove the alias property
374 propertyIt.remove();
375 }
376 else
377 {
378 // An alias to an array item,
379 // create the array and transplant the property.
380 baseNode = new XMPNode(info.getPrefix() + info.getPropName(), info
381 .getAliasForm().toPropertyOptions());
382 baseSchema.addChild(baseNode);
383 transplantArrayItemAlias (propertyIt, currProp, baseNode);
384 }
385
386 }
387 else if (info.getAliasForm().isSimple())
388 {
389 // The base node does exist and this is a top-to-top alias.
390 // Check for conflicts if strict aliasing is on.
391 // Remove and delete the alias subtree.
392 if (strictAliasing)
393 {
394 compareAliasedSubtrees (currProp, baseNode, true);
395 }
396
397 propertyIt.remove();
398 }
399 else
400 {
401 // This is an alias to an array item and the array exists.
402 // Look for the aliased item.
403 // Then transplant or check & delete as appropriate.
404
405 XMPNode itemNode = null;
406 if (info.getAliasForm().isArrayAltText())
407 {
408 int xdIndex = XMPNodeUtils.lookupLanguageItem(baseNode,
409 XMPConst.X_DEFAULT);
410 if (xdIndex != -1)
411 {
412 itemNode = baseNode.getChild(xdIndex);
413 }
414 }
415 else if (baseNode.hasChildren())
416 {
417 itemNode = baseNode.getChild(1);
418 }
419
420 if (itemNode == null)
421 {
422 transplantArrayItemAlias (propertyIt, currProp, baseNode);
423 }
424 else
425 {
426 if (strictAliasing)
427 {
428 compareAliasedSubtrees (currProp, itemNode, true);
429 }
430
431 propertyIt.remove();
432 }
433 }
434 }
435 }
436 currSchema.setHasAliases(false);
437 }
438 }
439
440
441 /**
442 * Moves an alias node of array form to another schema into an array
443 * @param propertyIt the property iterator of the old schema (used to delete the property)
444 * @param childNode the node to be moved
445 * @param baseArray the base array for the array item
446 * @throws XMPException Forwards XMP errors
447 */
448 private static void transplantArrayItemAlias(Iterator propertyIt, XMPNode childNode,
449 XMPNode baseArray) throws XMPException
450 {
451 if (baseArray.getOptions().isArrayAltText())
452 {
453 if (childNode.getOptions().getHasLanguage())
454 {
455 // *** Allow x-default.
456 throw new XMPException("Alias to x-default already has a language qualifier",
457 XMPError.BADXMP);
458 }
459
460 XMPNode langQual = new XMPNode(XMPConst.XML_LANG, XMPConst.X_DEFAULT, null);
461 childNode.addQualifier(langQual);
462 }
463
464 propertyIt.remove();
465 childNode.setName(XMPConst.ARRAY_ITEM_NAME);
466 baseArray.addChild(childNode);
467 }
468
469
470 /**
471 * Fixes the GPS Timestamp in EXIF.
472 * @param exifSchema the EXIF schema node
473 * @throws XMPException Thrown if the date conversion fails.
474 */
475 private static void fixGPSTimeStamp(XMPNode exifSchema)
476 throws XMPException
477 {
478 // Note: if dates are not found the convert-methods throws an exceptions,
479 // and this methods returns.
480 XMPNode gpsDateTime = XMPNodeUtils.findChildNode(exifSchema, "exif:GPSTimeStamp", false);
481 if (gpsDateTime == null)
482 {
483 return;
484 }
485
486 try
487 {
488 XMPDateTime binGPSStamp;
489 XMPDateTime binOtherDate;
490
491 binGPSStamp = XMPUtils.convertToDate(gpsDateTime.getValue());
492 if (binGPSStamp.getYear() != 0 ||
493 binGPSStamp.getMonth() != 0 ||
494 binGPSStamp.getDay() != 0)
495 {
496 return;
497 }
498
499 XMPNode otherDate = XMPNodeUtils.findChildNode(exifSchema, "exif:DateTimeOriginal",
500 false);
501 if (otherDate == null)
502 {
503 otherDate = XMPNodeUtils.findChildNode(exifSchema, "exif:DateTimeDigitized", false);
504 }
505 if(otherDate == null)
506 return;
507
508 binOtherDate = XMPUtils.convertToDate(otherDate.getValue());
509 Calendar cal = binGPSStamp.getCalendar();
510 cal.set(Calendar.YEAR, binOtherDate.getYear());
511 cal.set(Calendar.MONTH, binOtherDate.getMonth());
512 cal.set(Calendar.DAY_OF_MONTH, binOtherDate.getDay());
513 binGPSStamp = new XMPDateTimeImpl(cal);
514 gpsDateTime.setValue(XMPUtils.convertFromDate (binGPSStamp));
515 }
516 catch (XMPException e)
517 {
518 // Don't let a missing or bad date stop other things.
519 return;
520 }
521 }
522
523
524
525 /**
526 * Remove all empty schemas from the metadata tree that were generated during the rdf parsing.
527 * @param tree the root of the metadata tree
528 */
529 private static void deleteEmptySchemas(XMPNode tree)
530 {
531 // Delete empty schema nodes. Do this last, other cleanup can make empty
532 // schema.
533
534 for (Iterator it = tree.iterateChildren(); it.hasNext();)
535 {
536 XMPNode schema = (XMPNode) it.next();
537 if (!schema.hasChildren())
538 {
539 it.remove();
540 }
541 }
542 }
543
544
545 /**
546 * The outermost call is special. The names almost certainly differ. The
547 * qualifiers (and hence options) will differ for an alias to the x-default
548 * item of a langAlt array.
549 *
550 * @param aliasNode the alias node
551 * @param baseNode the base node of the alias
552 * @param outerCall marks the outer call of the recursion
553 * @throws XMPException Forwards XMP errors
554 */
555 private static void compareAliasedSubtrees(XMPNode aliasNode, XMPNode baseNode,
556 boolean outerCall) throws XMPException
557 {
558 if (!aliasNode.getValue().equals(baseNode.getValue()) ||
559 aliasNode.getChildrenLength() != baseNode.getChildrenLength())
560 {
561 throw new XMPException("Mismatch between alias and base nodes", XMPError.BADXMP);
562 }
563
564 if (
565 !outerCall &&
566 (!aliasNode.getName().equals(baseNode.getName()) ||
567 !aliasNode.getOptions().equals(baseNode.getOptions()) ||
568 aliasNode.getQualifierLength() != baseNode.getQualifierLength())
569 )
570 {
571 throw new XMPException("Mismatch between alias and base nodes",
572 XMPError.BADXMP);
573 }
574
575 for (Iterator an = aliasNode.iterateChildren(),
576 bn = baseNode.iterateChildren();
577 an.hasNext() && bn.hasNext();)
578 {
579 XMPNode aliasChild = (XMPNode) an.next();
580 XMPNode baseChild = (XMPNode) bn.next();
581 compareAliasedSubtrees (aliasChild, baseChild, false);
582 }
583
584
585 for (Iterator an = aliasNode.iterateQualifier(),
586 bn = baseNode.iterateQualifier();
587 an.hasNext() && bn.hasNext();)
588 {
589 XMPNode aliasQual = (XMPNode) an.next();
590 XMPNode baseQual = (XMPNode) bn.next();
591 compareAliasedSubtrees (aliasQual, baseQual, false);
592 }
593 }
594
595
596 /**
597 * The initial support for WAV files mapped a legacy ID3 audio copyright
598 * into a new xmpDM:copyright property. This is special case code to migrate
599 * that into dc:rights['x-default']. The rules:
600 *
601 * <pre>
602 * 1. If there is no dc:rights array, or an empty array -
603 * Create one with dc:rights['x-default'] set from double linefeed and xmpDM:copyright.
604 *
605 * 2. If there is a dc:rights array but it has no x-default item -
606 * Create an x-default item as a copy of the first item then apply rule #3.
607 *
608 * 3. If there is a dc:rights array with an x-default item,
609 * Look for a double linefeed in the value.
610 * A. If no double linefeed, compare the x-default value to the xmpDM:copyright value.
611 * A1. If they match then leave the x-default value alone.
612 * A2. Otherwise, append a double linefeed and
613 * the xmpDM:copyright value to the x-default value.
614 * B. If there is a double linefeed, compare the trailing text to the xmpDM:copyright value.
615 * B1. If they match then leave the x-default value alone.
616 * B2. Otherwise, replace the trailing x-default text with the xmpDM:copyright value.
617 *
618 * 4. In all cases, delete the xmpDM:copyright property.
619 * </pre>
620 *
621 * @param xmp the metadata object
622 * @param dmCopyright the "dm:copyright"-property
623 */
624 private static void migrateAudioCopyright (XMPMeta xmp, XMPNode dmCopyright)
625 {
626 try
627 {
628 XMPNode dcSchema = XMPNodeUtils.findSchemaNode(
629 ((XMPMetaImpl) xmp).getRoot(), XMPConst.NS_DC, true);
630
631 String dmValue = dmCopyright.getValue();
632 String doubleLF = "\n\n";
633
634 XMPNode dcRightsArray = XMPNodeUtils.findChildNode (dcSchema, "dc:rights", false);
635
636 if (dcRightsArray == null || !dcRightsArray.hasChildren())
637 {
638 // 1. No dc:rights array, create from double linefeed and xmpDM:copyright.
639 dmValue = doubleLF + dmValue;
640 xmp.setLocalizedText(XMPConst.NS_DC, "rights", "", XMPConst.X_DEFAULT, dmValue,
641 null);
642 }
643 else
644 {
645 int xdIndex = XMPNodeUtils.lookupLanguageItem(dcRightsArray, XMPConst.X_DEFAULT);
646
647 if (xdIndex < 0)
648 {
649 // 2. No x-default item, create from the first item.
650 String firstValue = dcRightsArray.getChild(1).getValue();
651 xmp.setLocalizedText (XMPConst.NS_DC, "rights", "", XMPConst.X_DEFAULT,
652 firstValue, null);
653 xdIndex = XMPNodeUtils.lookupLanguageItem(dcRightsArray, XMPConst.X_DEFAULT);
654 }
655
656 // 3. Look for a double linefeed in the x-default value.
657 XMPNode defaultNode = dcRightsArray.getChild(xdIndex);
658 String defaultValue = defaultNode.getValue();
659 int lfPos = defaultValue.indexOf(doubleLF);
660
661 if (lfPos < 0)
662 {
663 // 3A. No double LF, compare whole values.
664 if (!dmValue.equals(defaultValue))
665 {
666 // 3A2. Append the xmpDM:copyright to the x-default
667 // item.
668 defaultNode.setValue(defaultValue + doubleLF + dmValue);
669 }
670 }
671 else
672 {
673 // 3B. Has double LF, compare the tail.
674 if (!defaultValue.substring(lfPos + 2).equals(dmValue))
675 {
676 // 3B2. Replace the x-default tail.
677 defaultNode.setValue(defaultValue.substring(0, lfPos + 2) + dmValue);
678 }
679 }
680
681 }
682
683 // 4. Get rid of the xmpDM:copyright.
684 dmCopyright.getParent().removeChild(dmCopyright);
685 }
686 catch (XMPException e)
687 {
688 // Don't let failures (like a bad dc:rights form) stop other
689 // cleanup.
690 }
691 }
692
693
694 /**
695 * Initializes the map that contains the known arrays, that are fixed by
696 * {@link XMPNormalizer#normalizeDCArrays(XMPNode)}.
697 */
698 private static void initDCArrays()
699 {
700 dcArrayForms = new HashMap();
701
702 // Properties supposed to be a "Bag".
703 PropertyOptions bagForm = new PropertyOptions();
704 bagForm.setArray(true);
705 dcArrayForms.put("dc:contributor", bagForm);
706 dcArrayForms.put("dc:language", bagForm);
707 dcArrayForms.put("dc:publisher", bagForm);
708 dcArrayForms.put("dc:relation", bagForm);
709 dcArrayForms.put("dc:subject", bagForm);
710 dcArrayForms.put("dc:type", bagForm);
711
712 // Properties supposed to be a "Seq".
713 PropertyOptions seqForm = new PropertyOptions();
714 seqForm.setArray(true);
715 seqForm.setArrayOrdered(true);
716 dcArrayForms.put("dc:creator", seqForm);
717 dcArrayForms.put("dc:date", seqForm);
718
719 // Properties supposed to be an "Alt" in alternative-text form.
720 PropertyOptions altTextForm = new PropertyOptions();
721 altTextForm.setArray(true);
722 altTextForm.setArrayOrdered(true);
723 altTextForm.setArrayAlternate(true);
724 altTextForm.setArrayAltText(true);
725 dcArrayForms.put("dc:description", altTextForm);
726 dcArrayForms.put("dc:rights", altTextForm);
727 dcArrayForms.put("dc:title", altTextForm);
728 }
729 }