private List <String> ParseQuestions(XmlReader reader) { var questions = new List <string>(); reader.ReadToFollowing("CmDomainQ"); while (reader.IsStartElement("CmDomainQ")) { XmlReader cmDomainQReader = reader.ReadSubtree(); cmDomainQReader.ReadToFollowing("Question"); MultiText mtQuestion = ParseMultiStringElement(cmDomainQReader, false); string question = mtQuestion.GetBestAlternative(SemanticDomainWs); cmDomainQReader.ReadToFollowing("ExampleWords"); MultiText mtExampleWords = ParseMultiStringElement(cmDomainQReader, true); string exampleWords = mtExampleWords.GetBestAlternative(SemanticDomainWs); if (!String.IsNullOrEmpty(question)) { string formattedQuestion = ""; if (!String.IsNullOrEmpty((exampleWords))) { formattedQuestion = question + " (" + exampleWords + ")"; } else { formattedQuestion = question; } questions.Add(formattedQuestion); } cmDomainQReader.Close(); reader.ReadToNextSibling("CmDomainQ"); } return(questions); }
public static IEnumerable <string> SplitGlossAtSemicolon(MultiText gloss, string writingSystemId) { bool exact = true; string glossText = gloss.GetExactAlternative(writingSystemId); if (glossText == string.Empty) { exact = false; glossText = gloss.GetBestAlternative(writingSystemId, "*"); if (glossText == "*") { glossText = string.Empty; } } List <string> result = new List <string>(); string[] keylist = glossText.Split(new char[] { ';' }); for (int i = 0; i < keylist.Length; i++) { string k = keylist[i].Trim(); if (/*keylist.Length > 1 &&*/ k.Length == 0) { continue; } if (exact || i == keylist.Length - 1) { result.Add(k); } else { result.Add(k + "*"); } } return(result); }
public static IEnumerable<string> SplitGlossAtSemicolon(MultiText gloss, string writingSystemId) { bool exact = true; string glossText = gloss.GetExactAlternative(writingSystemId); if (glossText == string.Empty) { exact = false; glossText = gloss.GetBestAlternative(writingSystemId, "*"); if (glossText == "*") { glossText = string.Empty; } } List<string> result = new List<string>(); string[] keylist = glossText.Split(new char[] { ';' }); for (int i = 0; i < keylist.Length; i++) { string k = keylist[i].Trim(); if (/*keylist.Length > 1 &&*/ k.Length == 0) { continue; } if (exact || i == keylist.Length - 1) { result.Add(k); } else { result.Add(k + "*"); } } return result; }
private static string RenderField(MultiText text, CurrentItemEventArgs currentItem, int sizeBoost, Field field) { StringBuilder rtfBuilder = new StringBuilder(); if (text != null) { if (text.Count == 0 && currentItem != null && text == currentItem.DataTarget) { rtfBuilder.Append(RenderBlankPosition()); } if (field == null) // show them all { foreach (LanguageForm l in text) { RenderForm(text, currentItem, rtfBuilder, l, sizeBoost); } } else //todo: show all those turned on for the field? { LanguageForm form = text.GetBestAlternative(field.WritingSystemIds); if (form != null) { RenderForm(text, currentItem, rtfBuilder, form, sizeBoost); } } } return rtfBuilder.ToString(); }