/// <summary>
        /// Validates the data content of a set of elements by locating the scheme
        /// identified by the scheme attribute.
        /// </summary>
        /// <param name="list">An <see cref="XmlNodeList"/> of elements to check.</param>
        /// <param name="errorHandler">The <see cref="ValidationErrorHandler"/> used to report issues.</param>
        /// <returns><c>true</c> if the code values pass the checks, <c>false</c>
        /// otherwise.</returns>
        protected bool Validate(XmlNodeList list, ValidationErrorHandler errorHandler)
        {
            bool result = true;

            if (list.Count > 0)
            {
                XmlElement fpml    = DOM.GetParent(list [0] as XmlElement);
                string     version = null;

                // Find the FpML root node
                while (fpml != null)
                {
                    if (fpml.LocalName.Equals("FpML"))
                    {
                        version = fpml.GetAttribute("version");
                        break;
                    }
                    if (fpml.HasAttribute("fpmlVersion"))
                    {
                        version = fpml.GetAttribute("fpmlVersion");
                        break;
                    }
                    fpml = DOM.GetParent(fpml);
                }

                SchemeCollection schemes =
                    (Releases.FPML.GetReleaseForVersion(version) as ISchemeAccess).SchemeCollection;

                foreach (XmlElement context in list)
                {
                    string uri = context.GetAttribute(attributeName);

                    if ((uri == null) || (uri.Length == 0))
                    {
                        errorHandler("305", context,
                                     "A qualifying scheme URI has not been defined for this element",
                                     DisplayName, context.LocalName);

                        result = false;
                        continue;
                    }

                    Scheme scheme = schemes.FindSchemeForUri(uri);
                    if (scheme == null)
                    {
                        errorHandler("305", context,
                                     "An unrecognized scheme URI has been used as a qualifier",
                                     DisplayName, uri);

                        result = false;
                        continue;
                    }

                    string value = context.InnerText.Trim();
                    if (scheme.IsValid(value))
                    {
                        continue;
                    }

                    errorHandler("305", context,
                                 "The code value '" + value + "' is not valid in scheme '" + scheme.Uri + "'",
                                 DisplayName, value);

                    result = false;
                }
            }
            return(result);
        }
        /// <summary>
        /// Validates the data content of a set of elements by locating the scheme
        /// identified by the scheme attribute or a default on the root element
        /// for pre FpML-4-0 instances.
        /// </summary>
        /// <param name="list">An <see cref="XmlNodeList"/> of elements to check.</param>
        /// <param name="errorHandler">The <see cref="ValidationErrorHandler"/> used to report issues.</param>
        /// <returns><c>true</c> if the code values pass the checks, <c>false</c>
        /// otherwise.</returns>
        protected bool Validate(XmlNodeList list, ValidationErrorHandler errorHandler)
        {
            bool result = true;

            if (list.Count > 0)
            {
                XmlElement fpml    = DOM.GetParent(list [0] as XmlElement);
                string     version = null;

                // Find the FpML root node
                while (fpml != null)
                {
                    if (fpml.LocalName.Equals("FpML"))
                    {
                        version = fpml.GetAttribute("version");
                        break;
                    }
                    if (fpml.HasAttribute("fpmlVersion"))
                    {
                        version = fpml.GetAttribute("fpmlVersion");
                        break;
                    }
                    fpml = DOM.GetParent(fpml);
                }

                Release release = Releases.FPML.GetReleaseForVersion(version);
                if (release == null)
                {
                    errorHandler("305", null,
                                 "The document release is not on the schema set -- Check configuration",
                                 DisplayName, null);
                }

                SchemeCollection schemes = (release as ISchemeAccess).SchemeCollection;
                if (schemes == null)
                {
                    errorHandler("305", null,
                                 "No schemes data is available for this FpML version -- Check configuration",
                                 DisplayName, null);
                }

                foreach (XmlElement context in list)
                {
                    // If there is no local override then look for a default on the FpML
                    // element in pre 3-0 versions.
                    string uri = context.GetAttribute(attributeName);
                    if (((uri == null) || (uri.Length == 0)) && (version != null))
                    {
                        string [] components = version.Split('-');
                        if ((components.Length > 1) && (components [0].CompareTo("4") < 0))
                        {
                            ISchemeAccess provider
                                = Specification.ReleaseForDocument(context.OwnerDocument) as ISchemeAccess;

                            string name = provider.SchemeDefaults.GetDefaultAttributeForScheme(attributeName);
                            if (name != null)
                            {
                                uri = fpml.GetAttribute(name);
                            }
                        }
                    }

                    if ((uri == null) || (uri.Length == 0))
                    {
                        errorHandler("305", context,
                                     "A qualifying scheme URI has not been defined for this element",
                                     DisplayName, context.LocalName);

                        result = false;
                        continue;
                    }

                    Scheme scheme = schemes.FindSchemeForUri(uri);
                    if (scheme == null)
                    {
                        errorHandler("305", context,
                                     "An unrecognized scheme URI has been used as a qualifier",
                                     DisplayName, uri);

                        result = false;
                        continue;
                    }

                    string value = context.InnerText.Trim();
                    if (scheme.IsValid(value))
                    {
                        continue;
                    }

                    errorHandler("305", context,
                                 "The code value '" + value + "' is not valid in scheme '" + scheme.Uri + "'",
                                 DisplayName, value);

                    result = false;
                }
            }
            return(result);
        }