public ReplaceChild ( int index, |
||
index | int | the index of the node that will be replaced. /// Note: The node children are indexed from [1..size]! |
node | the replacement XMPNode | |
return | void |
/// <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. <br> /// The <code>xml:lang</code> attribute was dropped from an /// <code>alt-text</code> item if the language was <code>x-default</code>. /// </summary> /// <param name="dcSchema"> the DC schema node </param> /// <exception cref="XmpException"> Thrown if normalization fails </exception> private static void NormalizeDcArrays(XmpNode dcSchema) { for (int i = 1; i <= dcSchema.ChildrenLength; i++) { XmpNode currProp = dcSchema.GetChild(i); PropertyOptions arrayForm = (PropertyOptions)_dcArrayForms[currProp.Name]; if (arrayForm == null) { continue; } if (currProp.Options.Simple) { // create a new array and add the current property as child, // if it was formerly simple XmpNode newArray = new XmpNode(currProp.Name, arrayForm); currProp.Name = XmpConst.ARRAY_ITEM_NAME; newArray.AddChild(currProp); dcSchema.ReplaceChild(i, newArray); // fix language alternatives if (arrayForm.ArrayAltText && !currProp.Options.HasLanguage) { XmpNode newLang = new XmpNode(XmpConst.XML_LANG, XmpConst.X_DEFAULT, null); currProp.AddQualifier(newLang); } } else { // clear array options and add corrected array form if it has been an array before currProp.Options.SetOption( PropertyOptions.ARRAY | PropertyOptions.ARRAY_ORDERED | PropertyOptions.ARRAY_ALTERNATE | PropertyOptions.ARRAY_ALT_TEXT, false); currProp.Options.MergeWith(arrayForm); if (arrayForm.ArrayAltText) { // applying for "dc:description", "dc:rights", "dc:title" RepairAltText(currProp); } } } }
/// <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. <br> /// The <code>xml:lang</code> attribute was dropped from an /// <code>alt-text</code> item if the language was <code>x-default</code>. /// </summary> /// <param name="dcSchema"> the DC schema node </param> /// <exception cref="XmpException"> Thrown if normalization fails </exception> private static void NormalizeDcArrays(XmpNode dcSchema) { for (int i = 1; i <= dcSchema.ChildrenLength; i++) { XmpNode currProp = dcSchema.GetChild(i); PropertyOptions arrayForm = (PropertyOptions) _dcArrayForms[currProp.Name]; if (arrayForm == null) { continue; } if (currProp.Options.Simple) { // create a new array and add the current property as child, // if it was formerly simple XmpNode newArray = new XmpNode(currProp.Name, arrayForm); currProp.Name = XmpConst.ARRAY_ITEM_NAME; newArray.AddChild(currProp); dcSchema.ReplaceChild(i, newArray); // fix language alternatives if (arrayForm.ArrayAltText && !currProp.Options.HasLanguage) { XmpNode newLang = new XmpNode(XmpConst.XML_LANG, XmpConst.X_DEFAULT, null); currProp.AddQualifier(newLang); } } else { // clear array options and add corrected array form if it has been an array before currProp.Options.SetOption( PropertyOptions.ARRAY | PropertyOptions.ARRAY_ORDERED | PropertyOptions.ARRAY_ALTERNATE | PropertyOptions.ARRAY_ALT_TEXT, false); currProp.Options.MergeWith(arrayForm); if (arrayForm.ArrayAltText) { // applying for "dc:description", "dc:rights", "dc:title" RepairAltText(currProp); } } } }