internal LocalPolicyCatalogueCache(LocalPolicyCatalogueCache existing)
		{
			m_content = existing.m_content;
			foreach (LocalPolicyLanguageTableCache existingLang in existing.Languages)
			{
				LocalPolicyLanguageTableCache newLang = new LocalPolicyLanguageTableCache(existingLang);
                newLang.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);
                
				m_languages.Add(newLang);
			}
		}
		internal LocalPolicySetVersionCache(LocalPolicySetVersionCache existing, string version, bool latest, PolicySetVersionStatus status)
		{
			m_name = existing.m_name;
			m_version = version;
			m_content = existing.Content;
			m_Status = status;


            if (existing.MasterCatalogue != null)
            {
                LocalPolicyCatalogueCache master = new LocalPolicyCatalogueCache(existing.MasterCatalogue as LocalPolicyCatalogueCache);
                master.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);
                m_masterCatalogue = master;
            }


			if (existing.m_refCatalogues != null)
			{
				foreach (LocalPolicyCatalogueCache existingCat in existing.m_refCatalogues)
				{
					LocalPolicyCatalogueCache newCat = new LocalPolicyCatalogueCache(existingCat);
                    newCat.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);
					m_refCatalogues.Add(newCat);
				}
			}


			if (existing.m_compiledSets != null)
			{
				foreach (LocalCompiledPolicySetCache existingCPS in existing.m_compiledSets)
				{
					LocalCompiledPolicySetCache newCPS = new LocalCompiledPolicySetCache(existingCPS);
                    newCPS.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);
					m_compiledSets.Add(newCPS);
				}
			}

			Latest = latest;
		}
		private void LoadPolicySetVersion(string xml)
		{
			XmlDocument xmlDoc = new XmlDocument();
			xmlDoc.LoadXml(xml);

			m_name = xmlDoc.DocumentElement.Attributes.GetNamedItem("name").Value;

            try 
			{ 
				ID = Convert.ToInt64(xmlDoc.DocumentElement.Attributes.GetNamedItem("id").Value, CultureInfo.InvariantCulture);
			}
			catch( Exception ex)
			{
				Logger.LogError("Unable to retrieve id from local policy file");
				Logger.LogError(ex);
			}


			// read all the xml and extract out elements to create catalogues and languages, etc
			m_content = xmlDoc.SelectSingleNode("/PolicySet/Content").InnerXml;

			XmlNodeList catalogues = xmlDoc.SelectNodes("/PolicySet/Catalogues/Catalogue");
			foreach (XmlNode catalogue in catalogues)
			{
				string cat_content = catalogue.SelectSingleNode("Content").InnerXml;

				LocalPolicyCatalogueCache cat = new LocalPolicyCatalogueCache(cat_content);
                cat.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);

                try 
				{ 
					cat.ID = Convert.ToInt64(catalogue.Attributes.GetNamedItem("id").Value, CultureInfo.InvariantCulture); 
				}
				catch( Exception ex)
				{
	                Logger.LogError("Unable to retrieve id from local policy file");
					Logger.LogError(ex);
				}

                cat.LoadLanguages(catalogue.SelectNodes("Languages/Language"));

                if (catalogue.Attributes.GetNamedItem("master").Value == "true")
                    m_masterCatalogue = cat;
                else
                    m_refCatalogues.Add(cat);
			}
            AddCompiledPolicySets(xmlDoc);
		}
		public IPolicyCatalogueCache NewReferenceCatalgue(string content)
		{
            ValidateChanges();
			LocalPolicyCatalogueCache lpc = new LocalPolicyCatalogueCache(content);
            lpc.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);

			m_refCatalogues.Add(lpc);
			return lpc;
		}
		public IPolicyCatalogueCache NewMasterCatalogue(string content)
		{
            ValidateChanges();
			LocalPolicyCatalogueCache lpc = new LocalPolicyCatalogueCache(content);
            lpc.ObjectModified += new ObjectModifiedEventHandler(OnObjectModified);

			m_masterCatalogue = lpc;
			return m_masterCatalogue;
		}