Пример #1
0
 /// <summary>
 /// Undo the denormalization performed by the XMP used in Acrobat 5.<br />
 /// If a Dublin Core array had only one item, it was serialized as a simple
 /// property.
 /// </summary>
 /// <remarks>
 /// Undo the denormalization performed by the XMP used in Acrobat 5.<br />
 /// If a Dublin Core array had only one item, it was serialized as a simple
 /// property. <br />
 /// The <c>xml:lang</c> attribute was dropped from an
 /// <c>alt-text</c> item if the language was <c>x-default</c>.
 /// </remarks>
 /// <param name="dcSchema">the DC schema node</param>
 /// <exception cref="XmpException">Thrown if normalization fails</exception>
 private static void NormalizeDcArrays(XmpNode dcSchema)
 {
     for (var i = 1; i <= dcSchema.GetChildrenLength(); i++)
     {
         var currProp  = dcSchema.GetChild(i);
         var arrayForm = (PropertyOptions)_dcArrayForms[currProp.Name];
         if (arrayForm == null)
         {
             continue;
         }
         if (currProp.Options.IsSimple)
         {
             // create a new array and add the current property as child,
             // if it was formerly simple
             var newArray = new XmpNode(currProp.Name, arrayForm);
             currProp.Name = XmpConstants.ArrayItemName;
             newArray.AddChild(currProp);
             dcSchema.ReplaceChild(i, newArray);
             // fix language alternatives
             if (arrayForm.IsArrayAltText && !currProp.Options.HasLanguage)
             {
                 var newLang = new XmpNode(XmpConstants.XmlLang, XmpConstants.XDefault, null);
                 currProp.AddQualifier(newLang);
             }
         }
         else
         {
             // clear array options and add corrected array form if it has been an array before
             currProp.Options.SetOption(PropertyOptions.ArrayFlag | PropertyOptions.ArrayOrderedFlag | PropertyOptions.ArrayAlternateFlag | PropertyOptions.ArrayAltTextFlag, false);
             currProp.Options.MergeWith(arrayForm);
             if (arrayForm.IsArrayAltText)
             {
                 // applying for "dc:description", "dc:rights", "dc:title"
                 RepairAltText(currProp);
             }
         }
     }
 }