/// <summary> /// Initialises a new <see cref="XmlDocument"/> by adding required definitions to /// the structure indicated by its root <see cref="XmlElement"/>. /// </summary> /// <param name="release">The <see cref="SchemaRelease"/> being initialised.</param> /// <param name="root">The root <see cref="XmlElement"/> of the new document.</param> /// <param name="isDefaultNamespace"><b>true</b> if the default namespace is being initialised.</param> public override void Initialise(HandCoded.Meta.SchemaRelease release, XmlElement root, bool isDefaultNamespace) { base.Initialise(release, root, isDefaultNamespace); int majorVersion = Int32.Parse(release.Version.Split('-')[0]); if (majorVersion <= 4) { root.SetAttribute("version", release.Version); } else { root.SetAttribute("fpmlVersion", release.Version); } }
/// <summary> /// Determines if the <see cref="XmlDocument"/> could be an instance of the /// indicated <see cref="SchemaRelease"/>. Also checks that the FpML version /// attribute matches the <see cref="SchemaRelease"/> instance. /// </summary> /// <param name="release">The potential <see cref="SchemaRelease"/>.</param> /// <param name="document">The <see cref="XmlDocument"/> to be tested.</param> /// <returns><b>true</b> if the <see cref="XmlDocument"/> could be an /// instance of the indicated <see cref="SchemaRelease"/>.</returns> public override bool Recognises(HandCoded.Meta.SchemaRelease release, XmlDocument document) { if (base.Recognises(release, document)) { int majorVersion = Int32.Parse(release.Version.Split('-')[0]); if (majorVersion <= 4) { if (document.DocumentElement.GetAttribute("version").Equals(release.Version)) { return(true); } } else { if (document.DocumentElement.GetAttribute("fpmlVersion").Equals(release.Version)) { return(true); } } } return(false); }