コード例 #1
0
            public void showNode(XmlNode descriptionNode, XmlNamespaceManager nameSpace, howToShow func)
            {
                documentInfoNode = descriptionNode.SelectSingleNode("fb:document-info", nameSpace);

                authorNode      = documentInfoNode.SelectNodes("fb:author", nameSpace);
                programUsedNode = documentInfoNode.SelectSingleNode("fb:program-used", nameSpace);
                dateNode        = documentInfoNode.SelectSingleNode("fb:date", nameSpace);
                srcUrlNode      = documentInfoNode.SelectNodes("fb:src-url", nameSpace);
                srcOcrNode      = documentInfoNode.SelectSingleNode("fb:src-ocr", nameSpace);
                //TODO: разобраться с айди
                idNode      = documentInfoNode.SelectSingleNode("fb:id", nameSpace);
                versionNode = documentInfoNode.SelectSingleNode("fb:version", nameSpace);

                //В массив передаю только сингловые ноды
                massNodes[0] = programUsedNode; massNodes[1] = dateNode;
                massNodes[2] = srcOcrNode; massNodes[3] = idNode; massNodes[4] = versionNode;

                //Cоздаем переменніе для каждого нода
                string authorr = null; string progUsed = null;
                string date = null; string srcU = null;
                string srcO = null; string id = null; string version = null;

                //В массив помещаем только переменные для сингл нодов!
                massVars[0] = progUsed; massVars[1] = date;
                massVars[2] = srcO; massVars[3] = id; massVars[4] = version;

                //Заменил миллионы трай на 1 в цикле.
                //ПОРЯДОК НОДОВ В МАСИВЕ ДОЛЖЕН СОВПАДАТЬ С ПОРЯДКОМ ПЕРЕМЕННЫХ К НИМ ВО ВТОРОМ МАССИВЕ!!!!!
                for (int i = 0; i < massNodes.Length; i++)
                {
                    try
                    {
                        if (massNodes[i] != null)
                        {
                            massVars[i] = massNodes[i].InnerText;
                        }
                    }
                    catch { }
                }

                authorr = HelperFB2.structureAuthor(authorNode, nameSpace, false);
                //TODO: realise srcU node (not important)

                writeNodeText(func, authorr, massVars[0], massVars[1], srcU, massVars[2], massVars[3], massVars[4]);
            }
コード例 #2
0
            public void showNode(
                XmlNode descriptionNode,
                XmlNamespaceManager nameSpace,
                howToShow func)
            {
                titleInfoNode = descriptionNode.SelectSingleNode("fb:title-info", nameSpace);

                authorNodes     = titleInfoNode.SelectNodes("fb:author", nameSpace);
                translatorNodes = titleInfoNode.SelectNodes("fb:translator", nameSpace);
                genreNodes      = titleInfoNode.SelectNodes("fb:genre", nameSpace);
                //TODO:FictionBook Site get all variants of innerText for annotation
                annotationNode = titleInfoNode.SelectSingleNode("fb:annotation", nameSpace);
                dateNode       = titleInfoNode.SelectSingleNode("fb:date", nameSpace);

                //Poster
                coverPageNode = titleInfoNode.SelectSingleNode("fb:coverpage", nameSpace);
                imageNode     = coverPageNode.SelectSingleNode("fb:image", nameSpace);
                xlinkAttr     = imageNode.Attributes.GetNamedItem("xlink");
                xlinkHrefAttr = imageNode.Attributes.GetNamedItem("xlink:href");
                if (xlinkHrefAttr != null)
                {
                    posterID = xlinkHrefAttr.InnerText;
                }
                else if (xlinkAttr != null)
                {
                    posterID = xlinkAttr.InnerText;
                }
                else
                {
                    posterID = null;
                }

                string s = structureAnnotation(annotationNode, nameSpace); // Here

                string bookName = null;

                try
                {
                    if (titleInfoNode.SelectSingleNode("fb:book-title", nameSpace) != null)
                    {
                        bookName = titleInfoNode.SelectSingleNode("fb:book-title", nameSpace).InnerText;
                    }
                }
                catch { }

                //TODO?: parse keywords
                string keywords = null;

                try
                {
                    if (titleInfoNode.SelectSingleNode("fb:keyword", nameSpace) != null)
                    {
                        keywords = titleInfoNode.SelectSingleNode("fb:keyword", nameSpace).InnerText;
                    }
                }
                catch { keywords = null; }

                string dateValue = null;
                string dateInner = null;

                try
                {
                    if (dateNode != null)
                    {
                        if (dateNode.Attributes.GetNamedItem("value") != null)
                        {
                            dateValue = dateNode.Attributes.GetNamedItem("value").InnerText;
                        }
                        dateInner = dateNode.InnerText;
                    }
                }
                catch { dateValue = null; dateInner = null; }

                string publisher = null;

                try
                {
                    if (titleInfoNode.SelectSingleNode("fb:publisher", nameSpace) != null)
                    {
                        publisher = titleInfoNode.SelectSingleNode("fb:publisher", nameSpace).InnerText;
                    }
                }
                catch { publisher = null; }

                string lang = null;

                try
                {
                    if (titleInfoNode.SelectSingleNode("fb:lang", nameSpace) != null)
                    {
                        lang = titleInfoNode.SelectSingleNode("fb:lang", nameSpace).InnerText;
                        Dictionaries dict = new Dictionaries(Languages.RU);
                        lang = dict.languages[lang.ToLower()];
                    }
                }
                catch { lang = null; }

                string src_lang = null;

                try
                {
                    if (titleInfoNode.SelectSingleNode("fb:src-lang", nameSpace) != null)
                    {
                        src_lang = titleInfoNode.SelectSingleNode("fb:src-lang", nameSpace).InnerText;
                    }
                }
                catch { src_lang = null; }

                string trans = "";
                string au    = "";

                try
                {
                    if (translatorNodes != null && (translatorNodes.Count > 0))
                    {
                        trans = HelperFB2.structureAuthor(translatorNodes, nameSpace, true);
                    }
                    if (authorNodes != null && (authorNodes.Count > 0))
                    {
                        au = HelperFB2.structureAuthor(authorNodes, nameSpace, false);
                    }
                }
                catch { trans = ""; au = ""; }


                writeNodeText(func, au, trans, bookName, lang, dateValue, dateInner, s);
            }