// ## [NestingLevel] [DocumentElementName] End private static void WriteDocumentElementEnd(StreamWriter writer, DocumentElement docElement) { writer.Write(NLPTextDocumentFormat.DOCUMENT_ELEMENT_LINE_MARKER); writer.Write(' '); writer.Write(docElement.NestingLevel); writer.Write(' '); writer.Write(NLPTextDocumentFormat.ElemNameForElemType[docElement.Type]); writer.Write(' '); writer.Write(NLPTextDocumentFormat.DOCUMENT_ELEMENT_END); var groupElementWithTitle = docElement as GroupElementWithTitle; if (groupElementWithTitle != null) { if (!String.IsNullOrEmpty(groupElementWithTitle.Title)) { writer.Write(" <<"); var title = groupElementWithTitle.Title; if (title.Length > 47) { title = title.Substring(0, 47) + "..."; } writer.Write(title); writer.Write(">>"); } } writer.WriteLine(); }
// ## [NestingLevel] [Section|List|Table] Start ...title... // ## [NestingLevel] ListItem Start // ## [NestingLevel] [TableHeader|TableCell] Start row,col // ## [NestingLevel] [TableHeader|TableCell] Start row:rowspan,col:colspan private static void WriteDocumentElementStart(StreamWriter writer, DocumentElement docElement) { if (docElement.Type == DocumentElementType.Section || docElement.Type == DocumentElementType.List || docElement.Type == DocumentElementType.Table) { writer.WriteLine(); } writer.Write(NLPTextDocumentFormat.DOCUMENT_ELEMENT_LINE_MARKER); writer.Write(' '); writer.Write(docElement.NestingLevel); writer.Write(' '); writer.Write(NLPTextDocumentFormat.ElemNameForElemType[docElement.Type]); writer.Write(' '); writer.Write(NLPTextDocumentFormat.DOCUMENT_ELEMENT_START); writer.Write(' '); switch (docElement.Type) { case DocumentElementType.Section: case DocumentElementType.List: case DocumentElementType.Table: var groupElement = (GroupElementWithTitle)docElement; writer.Write(groupElement.Title); break; case DocumentElementType.TableHeader: case DocumentElementType.TableCell: var tableElement = (TableElement)docElement; if (tableElement.RowSpan == 1 && tableElement.ColSpan == 1) { writer.Write(tableElement.Row); writer.Write(','); writer.Write(tableElement.Col); } else { writer.Write(tableElement.Row); writer.Write(':'); writer.Write(tableElement.RowSpan); writer.Write(','); writer.Write(tableElement.Col); writer.Write(':'); writer.Write(tableElement.ColSpan); } break; } writer.WriteLine(); }