Ejemplo n.º 1
0
 // Parse the metadata from the given element?
 private void ParseMetaCategories(DitaElement parentElement)
 {
     try
     {
         List <DitaElement> categoriesData = parentElement?.FindChildren("category");
         if (categoriesData != null)
         {
             foreach (DitaElement categoryData in categoriesData)
             {
                 foreach (DitaElement data in categoryData.Children)
                 {
                     if (data?.Attributes.ContainsKey("name") ?? false)
                     {
                         if (BookMeta.ContainsKey(data?.Attributes["name"]))
                         {
                             Trace.TraceWarning($"BookMeta already contains a value for {data?.Attributes["name"]}");
                         }
                         else
                         {
                             BookMeta.Add(data?.Attributes["name"], data?.Attributes["value"]);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Trace.TraceError(ex);
     }
 }
Ejemplo n.º 2
0
        // Build the internal structure based on a map
        private void ParseMap()
        {
            try
            {
                // Read the title
                BookTitle.Add("mainbooktitle", RootMap.Title);

                // Read the metadata
                ParseMapMeta();

                if (!BookMeta.ContainsKey("document title"))
                {
                    BookMeta.Add("document title", RootMap.Title);
                }

                // Add the chapters
                Chapters.AddRange(ParseChaptersFromFile(RootMap));

                // Removes any blank topics and replaces them with links to their first populate child
                RemoveBlankPages();
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex);
            }
        }