private Block ProcessChapterNode(XmlNode node) { var usxChapter = new UsxChapter(node); string chapterText; if (m_bookLevelChapterLabel != null) { // If this isn't the right order, the user would have had to enter a specific chapter label // for each chapter to format it correctly. chapterText = m_bookLevelChapterLabel + " " + usxChapter.ChapterNumber; } else { chapterText = usxChapter.ChapterNumber; } if (Int32.TryParse(usxChapter.ChapterNumber, out var chapterNum)) { m_currentChapter = chapterNum; } else { Debug.Fail("TODO: Deal with bogus chapter number in USX data!"); } m_currentStartVerse = 0; m_currentEndVerse = 0; var block = new Block(usxChapter.StyleTag, m_currentChapter) { IsParagraphStart = true, BookCode = m_bookId }; block.SetStandardCharacter(m_bookId, CharacterVerseData.StandardCharacter.BookOrChapter); block.BlockElements.Add(new ScriptText(chapterText)); return(block); }
private static void ExtractAnnotationsMarkedWithRqTag() { var directoryWithUsxFiles = @"C:\Users\Polk\Documents\Protoscript Generator\bundles\English Director Guide\WithApostrophes\bundle_text_dbl-5453af4c7644271c_pt-ENGDG_20160308-122600_release\USX_0"; var bookList = Directory.GetFiles(directoryWithUsxFiles, "*.usx").Select(f => new UsxDocument(f)).ToList(); string currentChapter = "0"; string currentVerse = "0"; foreach (var usxDocument in bookList.OrderBy(b => BCVRef.BookToNumber(b.BookId))) { foreach (XmlNode node in usxDocument.GetChaptersAndParas()) { if (node.Name == "chapter") { var usxChapter = new UsxChapter(node); currentChapter = usxChapter.ChapterNumber; currentVerse = "0"; } foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "verse") { currentVerse = childNode.Attributes.GetNamedItem("number").Value; } if (childNode.Name == "char") { if (childNode.Attributes["style"].Value == "rq") { Debug.WriteLine(usxDocument.BookId + "\t" + currentChapter + "\t" + currentVerse + "\t" + node.InnerText.Trim()); } } } } } }
private Block ProcessChapterNode(XmlNode node) { var usxChapter = new UsxChapter(node); string chapterText; if (m_bookLevelChapterLabel != null) { //TODO what if this isn't the right order? Is there any way we can know? chapterText = m_bookLevelChapterLabel + " " + usxChapter.ChapterNumber; } else { chapterText = usxChapter.ChapterNumber; } int chapterNum; if (Int32.TryParse(usxChapter.ChapterNumber, out chapterNum)) { m_currentChapter = chapterNum; } else { Debug.Fail("TODO: Deal with bogus chapter number in USX data!"); } m_currentStartVerse = 0; m_currentEndVerse = 0; var block = new Block(usxChapter.StyleTag, m_currentChapter) { IsParagraphStart = true }; block.SetStandardCharacter(m_bookId, CharacterVerseData.StandardCharacter.BookOrChapter); block.BlockElements.Add(new ScriptText(chapterText)); return(block); }
public void ChapterNumber_GetsCorrectStyleTagFromUsxChapter() { var usxChapter = new UsxChapter(m_nodes[0]); Assert.AreEqual("1", usxChapter.ChapterNumber); }