Example #1
0
        /// <summary>
        /// Parses the input source into an XMP metadata object, including
        /// de-aliasing and normalisation.
        /// </summary>
        /// <param name="input"> the input can be an <code>InputStream</code>, a <code>String</code> or
        ///             a byte buffer containing the XMP packet. </param>
        /// <param name="options"> the parse options </param>
        /// <returns> Returns the resulting XMP metadata object </returns>
        /// <exception cref="XmpException"> Thrown if parsing or normalisation fails. </exception>
        public static XMPMeta Parse(object input, ParseOptions options)
        {
            ParameterAsserts.AssertNotNull(input);
            options = options ?? new ParseOptions();

            XmlDocument document = ParseXml(input, options);

            bool xmpmetaRequired = options.RequireXmpMeta;

            object[] result = new object[3];
            result = FindRootNode(document, xmpmetaRequired, result);

            if (result != null && result[1] == XmpRdf)
            {
                XmpMetaImpl xmp = ParseRdf.Parse((XmlNode)result[0]);
                xmp.PacketHeader = (string)result[2];

                // Check if the XMP object shall be normalized
                if (!options.OmitNormalization)
                {
                    return(XmpNormalizer.Process(xmp, options));
                }
                return(xmp);
            }
            // no appropriate root node found, return empty metadata object
            return(new XmpMetaImpl());
        }
Example #2
0
 /// <seealso cref= XMPMeta#normalize(ParseOptions) </seealso>
 public virtual void Normalize(ParseOptions options)
 {
     if (options == null)
     {
         options = new ParseOptions();
     }
     XmpNormalizer.Process(this, options);
 }