예제 #1
0
        private void ReadFile(ConceptualItem parentItem, XmlReader reader)
        {
            XmlNodeType nodeType  = XmlNodeType.None;
            string      nodeName  = null;
            string      fileName  = null;
            string      fileTitle = null;

            while (reader.Read())
            {
                nodeType = reader.NodeType;
                if (nodeType == XmlNodeType.Element)
                {
                    nodeName = reader.Name;
                    if (String.Equals(nodeName, "file"))
                    {
                        fileName  = reader.GetAttribute("name");
                        fileTitle = reader.GetAttribute("title");
                        if (!String.IsNullOrEmpty(fileName) &&
                            !String.IsNullOrEmpty(fileTitle))
                        {
                            string          fullPath = Path.Combine(_contentDir, fileName);
                            ConceptualTopic docItem  = new ConceptualTopic(
                                new BuildFilePath(fullPath),
                                fileTitle, String.Empty);

                            docItem.Content = this;

                            docItem.BeginInit();

                            docItem.EndInit();

                            // handle the sub-item...
                            if (!reader.IsEmptyElement)
                            {
                                ReadFile(docItem, reader);
                            }

                            parentItem.Add(docItem);
                        }
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    nodeName = reader.Name;
                    if (String.Equals(nodeName, "file") ||
                        String.Equals(nodeName, "files"))
                    {
                        break;
                    }
                }
            }
        }
예제 #2
0
        private void ReadTopic(XmlReader reader, ConceptualContent content,
                               ConceptualItem parentItem)
        {
            XmlNodeType nodeType  = XmlNodeType.None;
            string      nodeName  = null;
            int         revNumber = 1;

            while (reader.Read())
            {
                nodeType = reader.NodeType;
                if (nodeType == XmlNodeType.Element)
                {
                    nodeName = reader.Name;
                    if (String.Equals(nodeName, "Topic"))
                    {
                        bool isVisible = true;

                        string docId = reader.GetAttribute("id");
                        if (ConceptualUtils.IsValidId(docId))
                        {
                            string textTemp = reader.GetAttribute("visible");
                            if (!String.IsNullOrEmpty(textTemp))
                            {
                                isVisible = Convert.ToBoolean(textTemp);
                            }

                            string docTitle = reader.GetAttribute("title");
                            if (!String.IsNullOrEmpty(docTitle))
                            {
                                string fullPath = Path.Combine(_contentDir,
                                                               docId + ".aml");
                                ConceptualTopic docItem = new ConceptualTopic(
                                    new BuildFilePath(fullPath), docTitle, docId);

                                docItem.Content = content;

                                docItem.BeginInit();

                                docItem.Visible        = isVisible;
                                docItem.TopicRevisions = revNumber;
                                //docItem.IncludesTopicId = true;

                                docItem.EndInit();

                                // handle the sub-item...
                                if (!reader.IsEmptyElement)
                                {
                                    ReadTopic(reader, content, docItem);
                                }

                                parentItem.Add(docItem);
                            }
                        }
                    }
                    else if (String.Equals(nodeName, "HelpKeyword"))
                    {
                        string index = reader.GetAttribute("index");
                        string term  = reader.GetAttribute("term");
                        if (!String.IsNullOrEmpty(index) &&
                            !String.IsNullOrEmpty(term))
                        {
                            KeywordItem keyword = new KeywordItem(
                                KeywordItem.ParseIndex(index), term);

                            parentItem.Keywords.Add(keyword);
                        }
                    }
                }
                else if (nodeType == XmlNodeType.EndElement)
                {
                    if (String.Equals(reader.Name, "Topic"))
                    {
                        break;
                    }
                }
            }
        }