internal static void NestContext(string linguisticsBaseDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var phonologyDir = Path.Combine(linguisticsBaseDir, SharedConstants.Phonology);

            if (!Directory.Exists(phonologyDir))
            {
                Directory.CreateDirectory(phonologyDir);
            }

            var langProjElement = wellUsedElements[SharedConstants.LangProject];

            // 1. Nest: LP's PhonologicalData(PhPhonData OA) (Also does PhPhonData's PhonRuleFeats(CmPossibilityList)
            // NB: PhPhonData is a singleton
            var phonDataPropElement = langProjElement.Element("PhonologicalData");
            var phonDataElement     = Utilities.CreateFromBytes(classData["PhPhonData"].Values.First());

            // 1.A. Write: Break out PhPhonData's PhonRuleFeats(CmPossibilityList OA) and write in its own .list file. (If it exists, but *before* nesting "PhPhonData".)
            FileWriterService.WriteNestedListFileIfItExists(
                classData, guidToClassMapping,
                phonDataElement, "PhonRuleFeats",
                Path.Combine(phonologyDir, SharedConstants.PhonRuleFeaturesFilename));
            phonDataPropElement.RemoveNodes();
            CmObjectNestingService.NestObject(
                false,
                phonDataElement,
                classData,
                guidToClassMapping);
            // 2. Nest: LP's PhFeatureSystem(FsFeatureSystem OA)
            var phonFeatureSystemPropElement = langProjElement.Element("PhFeatureSystem");
            var phonFeatureSystemElement     = Utilities.CreateFromBytes(classData["FsFeatureSystem"][phonFeatureSystemPropElement.Element(SharedConstants.Objsur).Attribute(SharedConstants.GuidStr).Value]);

            phonFeatureSystemPropElement.RemoveNodes();
            CmObjectNestingService.NestObject(
                false,
                phonFeatureSystemElement,
                classData,
                guidToClassMapping);
            // B. Write: LP's PhonologicalData(PhPhonData) (Sans its PhonRuleFeats(CmPossibilityList) in a new extension (phondata).
            FileWriterService.WriteNestedFile(Path.Combine(phonologyDir, SharedConstants.PhonologicalDataFilename), new XElement("PhonologicalData", phonDataElement));
            // C. Write: LP's PhFeatureSystem(FsFeatureSystem) in its own file with a new (shared extension of featsys).
            FileWriterService.WriteNestedFile(Path.Combine(phonologyDir, SharedConstants.PhonologyFeaturesFilename), new XElement(SharedConstants.FeatureSystem, phonFeatureSystemElement));
        }
        internal static void NestContext(string linguisticsBaseDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var morphAndSynDir = Path.Combine(linguisticsBaseDir, SharedConstants.MorphologyAndSyntax);

            if (!Directory.Exists(morphAndSynDir))
            {
                Directory.CreateDirectory(morphAndSynDir);
            }

            var lexDb = wellUsedElements[SharedConstants.LexDb];

            if (lexDb != null)
            {
                // Write out LexDb's "MorphTypes" list, as per AndyB (7 Feb 2012).
                FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                                lexDb, SharedConstants.MorphTypes,
                                                                Path.Combine(morphAndSynDir, SharedConstants.MorphTypesListFilename));
            }
            var langProjElement = wellUsedElements[SharedConstants.LangProject];
            // 1. Nest: LP's MorphologicalData(MoMorphData OA) (Also does MoMorphData's ProdRestrict(CmPossibilityList)
            //		Remove objsur node from LP.
            var morphologicalDataPropElement = langProjElement.Element("MorphologicalData");

            morphologicalDataPropElement.RemoveNodes();
            var morphDataElement = Utilities.CreateFromBytes(classData["MoMorphData"].Values.First());

            CmObjectNestingService.NestObject(
                false,
                morphDataElement,
                classData,
                guidToClassMapping);
            // Hold off writing it until its list is written.

            // 2. Nest: LP's MsFeatureSystem(FsFeatureSystem OA)
            //		Remove objsur node from LP.
            var morphFeatureSystemPropElement = langProjElement.Element("MsFeatureSystem");
            var morphFeatureSystemElement     = Utilities.CreateFromBytes(classData["FsFeatureSystem"][morphFeatureSystemPropElement.Element(SharedConstants.Objsur).Attribute(SharedConstants.GuidStr).Value]);

            morphFeatureSystemPropElement.RemoveNodes();
            CmObjectNestingService.NestObject(
                false,
                morphFeatureSystemElement,
                classData,
                guidToClassMapping);
            FileWriterService.WriteNestedFile(Path.Combine(morphAndSynDir, SharedConstants.MorphAndSynFeaturesFilename), new XElement(SharedConstants.FeatureSystem, morphFeatureSystemElement));

            // 3. Nest: LP's PartsOfSpeech(CmPossibilityList OA)
            //		Remove objsur node from LP.
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProjElement, SharedConstants.PartsOfSpeech,
                                                            Path.Combine(morphAndSynDir, SharedConstants.PartsOfSpeechFilename));

            // 4. Nest: LP's AnalyzingAgents(CmAgent OC) (use some new extension and a fixed name)
            //		Remove objsur node(s) from LP.
            var agents      = classData["CmAgent"];
            var rootElement = new XElement(SharedConstants.AnalyzingAgents);

            foreach (var agentGuid in BaseDomainServices.GetGuids(langProjElement, SharedConstants.AnalyzingAgents))
            {
                var agentElement = Utilities.CreateFromBytes(agents[agentGuid]);
                rootElement.Add(agentElement);
                CmObjectNestingService.NestObject(
                    false,
                    agentElement,
                    classData,
                    guidToClassMapping);
            }
            FileWriterService.WriteNestedFile(Path.Combine(morphAndSynDir, SharedConstants.AnalyzingAgentsFilename), rootElement);
            langProjElement.Element(SharedConstants.AnalyzingAgents).RemoveNodes();

            // A. Write: MoMorphData's ProdRestrict(CmPossibilityList OA) and write in its own .list file.
            //		Remove ProdRestrict node child in MoMorphData
            var prodRestrictPropElement = morphDataElement.Element("ProdRestrict");

            if (prodRestrictPropElement != null && prodRestrictPropElement.HasElements)
            {
                // NB: Write file, but only if morphDataElement has the list.
                FileWriterService.WriteNestedFile(Path.Combine(morphAndSynDir, "ProdRestrict." + SharedConstants.List), prodRestrictPropElement);
                prodRestrictPropElement.RemoveNodes();
            }

            // B. Write: LP's MorphologicalData(MoMorphData OA) in a new extension (morphdata)
            FileWriterService.WriteNestedFile(Path.Combine(morphAndSynDir, SharedConstants.MorphAndSynDataFilename), new XElement(SharedConstants.MorphAndSynData, morphDataElement));
        }
示例#3
0
        internal static void NestContext(string linguisticsBaseDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var textCorpusBaseDir = Path.Combine(linguisticsBaseDir, SharedConstants.TextCorpus);

            if (!Directory.Exists(textCorpusBaseDir))
            {
                Directory.CreateDirectory(textCorpusBaseDir);
            }

            var langProjElement = wellUsedElements[SharedConstants.LangProject];

            // Write Genre list (owning atomic CmPossibilityList)
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProjElement, SharedConstants.GenreList,
                                                            Path.Combine(textCorpusBaseDir, SharedConstants.GenreListFilename));

            // Write text markup tags list (owning atomic CmPossibilityList)
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProjElement, SharedConstants.TextMarkupTags,
                                                            Path.Combine(textCorpusBaseDir, SharedConstants.TextMarkupTagsListFilename));

            // Handle the LP TranslationTags prop (OA-CmPossibilityList), if it exists.
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProjElement, SharedConstants.TranslationTags,
                                                            Path.Combine(textCorpusBaseDir, SharedConstants.TranslationTagsListFilename));

            var texts = classData["Text"];

            if (texts.Count == 0)
            {
                return;                 // No texts to process.
            }
            if (MetadataCache.MdCache.ModelVersion < 7000059)
            {
                // Backwards compatible code.
                var textGuidsInLangProj = BaseDomainServices.GetGuids(langProjElement, "Texts");
                if (textGuidsInLangProj.Count == 0)
                {
                    return;                     //  None owned by lang project. (Some can be owned by RnGenericRec.)
                }
                foreach (var textGuid in textGuidsInLangProj)
                {
                    var rootElement = new XElement("TextInCorpus");
                    var textElement = Utilities.CreateFromBytes(texts[textGuid]);
                    rootElement.Add(textElement);
                    CmObjectNestingService.NestObject(
                        false,
                        textElement,
                        classData,
                        guidToClassMapping);
                    FileWriterService.WriteNestedFile(
                        Path.Combine(textCorpusBaseDir, "Text_" + textGuid.ToLowerInvariant() + "." + SharedConstants.TextInCorpus),
                        rootElement);
                }
                // Remove child objsur nodes from owning LangProg
                langProjElement.Element("Texts").RemoveNodes();
            }
            else
            {
                foreach (var textGuid in texts.Keys.ToArray())                 // Needs a copy, since the dictionary is changed.
                {
                    var rootElement = new XElement("TextInCorpus");
                    var textElement = Utilities.CreateFromBytes(texts[textGuid]);
                    rootElement.Add(textElement);
                    CmObjectNestingService.NestObject(
                        false,
                        textElement,
                        classData,
                        guidToClassMapping);
                    FileWriterService.WriteNestedFile(
                        Path.Combine(textCorpusBaseDir, "Text_" + textGuid.ToLowerInvariant() + "." + SharedConstants.TextInCorpus),
                        rootElement);
                }
            }
        }
        internal static void NestContext(string linguisticsBaseDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var lexDb = wellUsedElements[SharedConstants.LexDb];

            if (lexDb == null)
            {
                return;                 // No LexDb, then there can be no reversals.
            }
            SortedDictionary <string, byte[]> sortedInstanceData = classData["ReversalIndex"];

            if (sortedInstanceData.Count == 0)
            {
                return;                                     // no reversals, as in Lela-Teli-3.
            }
            lexDb.Element("ReversalIndexes").RemoveNodes(); // Restored in FlattenContext method.

            var reversalDir = Path.Combine(linguisticsBaseDir, ReversalRootFolder);

            if (!Directory.Exists(reversalDir))
            {
                Directory.CreateDirectory(reversalDir);
            }

            var srcDataCopy = new SortedDictionary <string, byte[]>(sortedInstanceData);

            foreach (var reversalIndexKvp in srcDataCopy)
            {
                var revIndexElement = Utilities.CreateFromBytes(reversalIndexKvp.Value);
                var ws          = revIndexElement.Element("WritingSystem").Element("Uni").Value;
                var revIndexDir = Path.Combine(reversalDir, ws);
                if (!Directory.Exists(revIndexDir))
                {
                    Directory.CreateDirectory(revIndexDir);
                }

                var reversalFilename = ws + ".reversal";

                // Break out ReversalIndex's PartsOfSpeech(CmPossibilityList OA) and write in its own .list file.
                FileWriterService.WriteNestedListFileIfItExists(
                    classData, guidToClassMapping,
                    revIndexElement, SharedConstants.PartsOfSpeech,
                    Path.Combine(revIndexDir, ws + "-" + SharedConstants.PartsOfSpeechFilename));

                CmObjectNestingService.NestObject(false, revIndexElement,
                                                  classData,
                                                  guidToClassMapping);

                var entriesElement = revIndexElement.Element("Entries");
                var root           = new XElement("Reversal",
                                                  new XElement(SharedConstants.Header, revIndexElement));
                if (entriesElement != null && entriesElement.Elements().Any())
                {
                    root.Add(entriesElement.Elements());
                    // NB: These were already sorted, way up in MultipleFileServices::CacheDataRecord, since "Entries" is a collection prop.
                    entriesElement.RemoveNodes();
                }

                FileWriterService.WriteNestedFile(Path.Combine(revIndexDir, reversalFilename), root);
            }
        }
        internal static void NestContext(XElement languageProjectElement,
                                         XElement scriptureElement,
                                         string baseDirectory,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            // baseDirectory is root/Scripture and has already been created by caller.
            var scriptureBaseDir = baseDirectory;

            // Split out the optional NoteCategories list.
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            scriptureElement, SharedConstants.NoteCategories,
                                                            Path.Combine(scriptureBaseDir, SharedConstants.NoteCategoriesListFilename));

            // Extract all 66 required 'ScrBookAnnotations' instances from BookAnnotations property, and write to corresponding subfolder.
            // Leave property, but emptied of <objsur elements>.
            var booksDir = Path.Combine(scriptureBaseDir, SharedConstants.Books);

            if (!Directory.Exists(booksDir))
            {
                Directory.CreateDirectory(booksDir);
            }
            var allAnnotations           = classData[SharedConstants.ScrBookAnnotations];
            var annotationObjSurElements = scriptureElement.Element(SharedConstants.BookAnnotations).Elements().ToList();

            scriptureElement.Element(SharedConstants.BookAnnotations).RemoveNodes();
            for (var canonicalBookNumber = 1; canonicalBookNumber < 67; ++canonicalBookNumber)
            {
                var paddedNumber             = ScriptureDomainServices.PaddedCanonicalBookNumer(canonicalBookNumber);
                var currentAnnotationElement = Utilities.CreateFromBytes(allAnnotations[annotationObjSurElements[canonicalBookNumber - 1].Attribute(SharedConstants.GuidStr).Value]);
                CmObjectNestingService.NestObject(false, currentAnnotationElement,
                                                  classData,
                                                  guidToClassMapping);
                FileWriterService.WriteNestedFile(
                    Path.Combine(booksDir, paddedNumber + "." + SharedConstants.bookannotations),
                    new XElement(SharedConstants.BookAnnotations, currentAnnotationElement));
            }

            // Extract any optional ScrBook instances from 'ScriptureBooks', and write each to corresponding subfolder.
            var allBooks = classData[SharedConstants.ScrBook];
            var scriptureBooksProperty = scriptureElement.Element(SharedConstants.ScriptureBooks);

            if (scriptureBooksProperty != null && scriptureBooksProperty.HasElements)
            {
                List <XElement> bookObjSurElements = scriptureElement.Element(SharedConstants.ScriptureBooks).Elements().ToList();
                scriptureElement.Element(SharedConstants.ScriptureBooks).RemoveNodes();
                foreach (var objsurEl in bookObjSurElements)
                {
                    var currentBookElement = Utilities.CreateFromBytes(allBooks[objsurEl.Attribute(SharedConstants.GuidStr).Value]);
                    var paddedNumber       = ScriptureDomainServices.PaddedCanonicalBookNumer(Int32.Parse(currentBookElement.Element("CanonicalNum").Attribute("val").Value));
                    CmObjectNestingService.NestObject(false, currentBookElement,
                                                      classData,
                                                      guidToClassMapping);
                    FileWriterService.WriteNestedFile(
                        Path.Combine(booksDir, paddedNumber + "." + SharedConstants.book),
                        new XElement(SharedConstants.Book, currentBookElement));
                }
            }

            CmObjectNestingService.NestObject(false, scriptureElement,
                                              classData,
                                              guidToClassMapping);

            FileWriterService.WriteNestedFile(
                Path.Combine(scriptureBaseDir, SharedConstants.ScriptureTransFilename),
                new XElement(SharedConstants.TranslatedScripture, scriptureElement));

            languageProjectElement.Element(SharedConstants.TranslatedScripture).RemoveNodes();
        }
        internal static void NestContext(string anthropologyDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var sortedInstanceData = classData["RnResearchNbk"];
            var langProj           = wellUsedElements[SharedConstants.LangProject];
            var headerElement      = new XElement(SharedConstants.Header);
            var rootElement        = new XElement(SharedConstants.Anthropology, headerElement);

            if (sortedInstanceData.Count > 0)
            {
                // 1. Main RnResearchNbk element.
                var notebookElement = Utilities.CreateFromBytes(sortedInstanceData.Values.First());
                headerElement.Add(notebookElement);

                CmObjectNestingService.NestObject(false, notebookElement,
                                                  classData,
                                                  guidToClassMapping);

                // Pull out the RecTypes OA pos list prop from RnResearchNbk and write as its own list file.
                // It is nested by now, if it exists at all.
                var recTypesOwningPropElement = notebookElement.Element("RecTypes");
                if (recTypesOwningPropElement != null && recTypesOwningPropElement.HasElements)
                {
                    FileWriterService.WriteNestedFile(
                        Path.Combine(anthropologyDir, "RecTypes." + SharedConstants.List),
                        new XElement("RecTypes", recTypesOwningPropElement.Element(SharedConstants.CmPossibilityList)));
                    recTypesOwningPropElement.RemoveNodes();
                }

                var recordsElement = notebookElement.Element("Records");
                if (recordsElement != null && recordsElement.HasElements)
                {
                    // Put nested (by this time) records all in as children of root.
                    rootElement.Add(recordsElement.Elements());       // NB: These were already sorted, way up in MultipleFileServices::CacheDataRecord, since "Records" is a collection prop.
                    recordsElement.RemoveNodes();                     // Leaves empty Records element placeholder in RnResearchNbk element.
                }
                // Remove child objsur nodes from owning LangProg
                langProj.Element("ResearchNotebook").RemoveNodes();
            }

            FileWriterService.WriteNestedFile(Path.Combine(anthropologyDir, SharedConstants.DataNotebookFilename), rootElement);

            // LangProj props to write. (List props will remain in lang proj, but the list obsur will be removed.)
            // Write each of several lists into individual files.

            /* Anthro-related lists owned by LangProj.
             *              case "AnthroList":
             *              case "ConfidenceLevels":
             *              case "Education":
             *              case "Locations":
             *              case "People":
             *              case "Positions":
             *              case "Restrictions":
             *              case "Roles":
             *              case "Status":
             *              case "TimeOfDay":
             */
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "AnthroList",
                                                            Path.Combine(anthropologyDir, "AnthroList." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "ConfidenceLevels",
                                                            Path.Combine(anthropologyDir, "ConfidenceLevels." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Education",
                                                            Path.Combine(anthropologyDir, "Education." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Locations",
                                                            Path.Combine(anthropologyDir, "Locations." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "People",
                                                            Path.Combine(anthropologyDir, "People." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Positions",
                                                            Path.Combine(anthropologyDir, "Positions." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Restrictions",
                                                            Path.Combine(anthropologyDir, "Restrictions." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Roles",
                                                            Path.Combine(anthropologyDir, "Roles." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "Status",
                                                            Path.Combine(anthropologyDir, "Status." + SharedConstants.List));
            FileWriterService.WriteNestedListFileIfItExists(classData, guidToClassMapping,
                                                            langProj, "TimeOfDay",
                                                            Path.Combine(anthropologyDir, "TimeOfDay." + SharedConstants.List));
        }
示例#7
0
        internal static void NestContext(string generalBaseDir,
                                         IDictionary <string, XElement> wellUsedElements,
                                         IDictionary <string, SortedDictionary <string, byte[]> > classData,
                                         Dictionary <string, string> guidToClassMapping)
        {
            var langProjElement = wellUsedElements[SharedConstants.LangProject];

            // LP AnnotationDefs (OA-CmPossibilityList). AnnotationDefs.list]
            FileWriterService.WriteNestedListFileIfItExists(classData,
                                                            guidToClassMapping,
                                                            langProjElement, SharedConstants.AnnotationDefs,
                                                            Path.Combine(generalBaseDir, SharedConstants.AnnotationDefsListFilename));

            // LP Styles (OC-StStyle) is used by everyone, but Scripture, so they go here.
            BaseDomainServices.NestStylesPropertyElement(
                classData,
                guidToClassMapping,
                langProjElement.Element(SharedConstants.Styles),
                Path.Combine(generalBaseDir, SharedConstants.FLExStylesFilename));

            // LP Filters (OC) can go into one filters file here. (FLExFilters.filter: new ext)
            var owningPropElement = langProjElement.Element(SharedConstants.Filters);

            if (owningPropElement != null && owningPropElement.HasElements)
            {
                var root = new XElement(SharedConstants.Filters);
                foreach (var filterObjSurElement in owningPropElement.Elements().ToList())
                {
                    var filterGuid    = filterObjSurElement.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant();
                    var className     = guidToClassMapping[filterGuid];
                    var filterElement = Utilities.CreateFromBytes(classData[className][filterGuid]);
                    CmObjectNestingService.NestObject(false, filterElement, classData, guidToClassMapping);
                    root.Add(filterElement);
                }
                FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExFiltersFilename), root);
                owningPropElement.RemoveNodes();
            }

            // LP Annotations (OC). Who still uses them? If all else fails, or they are used by several BCs, then store them in one file here.
            // [FLExAnnotations.annotation: new ext]
            // OJO! Sig is "CmAnnotation", which is abtract class, so handle like in Discourse-land.
            owningPropElement = langProjElement.Element(SharedConstants.Annotations);
            if (owningPropElement != null && owningPropElement.HasElements)
            {
                var root = new XElement(SharedConstants.Annotations);
                foreach (var annotationObjSurElement in owningPropElement.Elements().ToList())
                {
                    var annotationGuid    = annotationObjSurElement.Attribute(SharedConstants.GuidStr).Value.ToLowerInvariant();
                    var className         = guidToClassMapping[annotationGuid];
                    var annotationElement = Utilities.CreateFromBytes(classData[className][annotationGuid]);
                    CmObjectNestingService.NestObject(false, annotationElement, classData, guidToClassMapping);
                    BaseDomainServices.ReplaceElementNameWithAndAddClassAttribute(SharedConstants.CmAnnotation, annotationElement);
                    root.Add(annotationElement);
                }
                FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExAnnotationsFilename), root);
                owningPropElement.RemoveNodes();
            }

            // Some CmPicture instances may not be owned.
            var rootElement     = new XElement(SharedConstants.Pictures);
            var unownedPictures = classData[SharedConstants.CmPicture].Values.Where(listElement => XmlUtils.GetAttributes(listElement, new HashSet <string> {
                SharedConstants.OwnerGuid
            })[SharedConstants.OwnerGuid] == null).ToList();

            foreach (var unownedPictureBytes in unownedPictures)
            {
                var element = Utilities.CreateFromBytes(unownedPictureBytes);
                CmObjectNestingService.NestObject(
                    false,
                    element,
                    classData,
                    guidToClassMapping);
                rootElement.Add(element);
            }
            FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExUnownedPicturesFilename), rootElement);

            // No VirtualOrdering instances are owned.
            if (MetadataCache.MdCache.ModelVersion > MetadataCache.StartingModelVersion)
            {
                rootElement = new XElement(SharedConstants.VirtualOrderings);
                foreach (var element in classData[SharedConstants.VirtualOrdering].Values.ToArray().Select(virtualOrderingBytes => Utilities.CreateFromBytes(virtualOrderingBytes)))
                {
                    CmObjectNestingService.NestObject(
                        false,
                        element,
                        classData,
                        guidToClassMapping);
                    rootElement.Add(element);
                }
                FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.FLExVirtualOrderingFilename), rootElement);
            }

            // Yippee!! Write LP here. :-) [LanguageProject.langproj; new ext]
            CmObjectNestingService.NestObject(false,
                                              langProjElement,
                                              classData,
                                              guidToClassMapping);
            FileWriterService.WriteNestedFile(Path.Combine(generalBaseDir, SharedConstants.LanguageProjectFilename), new XElement(SharedConstants.LanguageProject, langProjElement));
        }