private void ReadFormNodes(XmlNodeList nodesWithForms, LiftMultiText text) { foreach (XmlNode formNode in nodesWithForms) { try { string lang = Utilities.GetStringAttribute(formNode, _wsAttributeLabel); XmlNode textNode = formNode.SelectSingleNode("text"); if (textNode != null) { // Add the separator if we need it. if (textNode.InnerText.Length > 0) { text.AddOrAppend(lang, "", "; "); } foreach (XmlNode node in textNode.ChildNodes) { if (node.Name == "span") { var span = text.AddSpan(lang, Utilities.GetOptionalAttributeString(node, "lang"), Utilities.GetOptionalAttributeString(node, "class"), Utilities.GetOptionalAttributeString(node, "href"), node.InnerText.Length); ReadSpanContent(text, lang, span, node); } else { text.AddOrAppend(lang, node.InnerText, ""); } } } var nodelist = formNode.SelectNodes("annotation"); if (nodelist != null) { foreach (XmlNode annotationNode in nodelist) { Annotation annotation = GetAnnotation(annotationNode); annotation.LanguageHint = lang; text.Annotations.Add(annotation); } } } catch (Exception e) { // not a fatal error NotifyFormatError(e); } } }
private void ReadSpanContent(LiftMultiText text, string lang, LiftSpan span, XmlNode node) { Debug.Assert(node.Name == "span"); foreach (XmlNode xn in node.ChildNodes) { if (xn.Name == "span") { var spanLang = Utilities.GetOptionalAttributeString(xn, "lang"); if (spanLang == lang) { spanLang = null; } var spanInner = new LiftSpan(text.LengthOfAlternative(lang), xn.InnerText.Length, spanLang, Utilities.GetOptionalAttributeString(xn, "class"), Utilities.GetOptionalAttributeString(xn, "href")); span.Spans.Add(spanInner); ReadSpanContent(text, lang, spanInner, xn); } else { text.AddOrAppend(lang, xn.InnerText, ""); } } }