private void writeKeyword(String keyword) throws SAXException { xhtml.startElement("span", "class", "java-keyword"); xhtml.characters(keyword); xhtml.endElement("span"); }
@Override public void endParagraph() { try { closeStyleTags(); if (pDepth == 1 && tableDepth == 0) { xhtml.endElement(paragraphTag); } else if (tableCellDepth > 0 && pWithinCell > 0){ xhtml.characters(NEWLINE, 0, 1); } else if (tableCellDepth == 0) { xhtml.characters(NEWLINE, 0, 1); } } catch (SAXException e) { } if (tableCellDepth > 0) { pWithinCell++; } pDepth--; }
xhtml.characters(NEWLINE, 0, 1); } catch (SAXException e) { xhtml.startElement(paragraphTag); } else { xhtml.startElement(paragraphTag, "class", styleClass);
private void writeIdentifier(String identifier) throws SAXException { xhtml.startElement("span", "class", "java-identifier"); xhtml.characters(identifier); xhtml.endElement("span"); }
public void visitEnd() { try { xhtml.characters("}\n"); xhtml.endElement("pre"); xhtml.endDocument(); } catch (SAXException e) { throw new RuntimeException(e); } }
xhtml.startElement("pre"); xhtml.characters(" " + packageName + ";\n"); xhtml.characters("{\n"); } catch (SAXException e) { throw new RuntimeException(e);
/** * Emits an XHTML element with the given text content. If the given * text value is null or empty, then the element is not written. * * @param name XHTML element name * @param value element value, possibly <code>null</code> * @throws SAXException if the content element could not be written */ public void element(String name, String value) throws SAXException { if (value != null && value.length() > 0) { startElement(name); characters(value); endElement(name); } }
/** * This assumes that the <p> was started before you get here. * And the user is required to close the <p> at the end of the document. * * These are currently handled by {@link #extract(WPInputStream, XHTMLContentHandler)}. * * @param xhtml * @throws SAXException */ protected void endParagraph(StringBuilder buffer, XHTMLContentHandler xhtml) throws SAXException { lazilyStartParagraph(xhtml); xhtml.characters(buffer.toString()); buffer.setLength(0); xhtml.endElement("p"); startedP = false; }
private void addHeaders(List<? extends Column> columns, XHTMLContentHandler xhtml) throws SAXException { xhtml.startElement("thead"); xhtml.startElement("tr"); for (Column c : columns) { xhtml.startElement("th"); xhtml.characters(c.getName()); xhtml.endElement("th"); } xhtml.endElement("tr"); xhtml.endElement("thead"); }
public void visitEnd() { try { xhtml.characters("}\n"); xhtml.endElement("pre"); xhtml.endDocument(); } catch (SAXException e) { throw new RuntimeException(e); } }
private void writeRow(DBFRow row, Charset charset, XHTMLContentHandler xhtml) throws SAXException { xhtml.startElement("tr"); for (DBFCell cell : row.cells) { xhtml.startElement("td"); xhtml.characters(cell.getString(charset)); xhtml.endElement("td"); } xhtml.endElement("tr"); } }
public void visitEnd() { try { xhtml.characters("}\n"); xhtml.endElement("pre"); xhtml.endDocument(); } catch (SAXException e) { throw new RuntimeException(e); } }
xhml.startElement(P); for (GlyphRun run : row) { xhml.characters(run.unicodeString); xhml.endElement(P);
/** * Reads the contents of the given stream and write it to the given XHTML * content handler. The stream is closed once fully processed. * * @param stream * Stream where is the result of ocr * @param xhtml * XHTML content handler * @throws SAXException * if the XHTML SAX events could not be handled * @throws IOException * if an input error occurred */ private void extractOutput(InputStream stream, XHTMLContentHandler xhtml) throws SAXException, IOException { xhtml.startElement("div", "class", "ocr"); try (Reader reader = new InputStreamReader(stream, UTF_8)) { char[] buffer = new char[1024]; for (int n = reader.read(buffer); n != -1; n = reader.read(buffer)) { if (n > 0) { xhtml.characters(buffer, 0, n); } } } xhtml.endElement("div"); }
if ("cm".equals(localName)) { xhtml.startElement("p", "class", "slide-comment"); xhtml.startElement("b"); boolean authorExists = false; if (authorString != null) { xhtml.characters(authorString.toString()); authorExists = true; xhtml.characters(" ("); xhtml.characters(authorInitials); xhtml.characters(")"); xhtml.endElement("b"); xhtml.characters(commentBuffer.toString()); xhtml.endElement("p");
private void extractSDT(XWPFSDT element, XHTMLContentHandler xhtml) throws SAXException, XmlException, IOException { ISDTContent content = element.getContent(); String tag = "p"; xhtml.startElement(tag); xhtml.characters(content.getText()); xhtml.endElement(tag); }
private void output(String what) throws SAXException { String text = null; if (pageCount == 1 && defaultFirst != null) { text = defaultFirst; } else if (pageCount % 2 == 0 && defaultEven != null) { text = defaultEven; } else { text = defaultOdd; } if (text != null) { xhtml.startElement("div", "class", "header"); xhtml.characters(text); if (hasAutoPageNumber) { if (autoPageNumberFormat == null) { // raw number xhtml.characters("\t" + pageCount); } else if (autoPageNumberFormat.equals("upper-roman")){ xhtml.characters("\t" + AutoPageNumberUtils.asRomanNumerals(pageCount)); } else if (autoPageNumberFormat.equals("lower-roman")){ xhtml.characters("\t" + AutoPageNumberUtils.asRomanNumeralsLower(pageCount)); } else if (autoPageNumberFormat.equals("upper-alpha")){ xhtml.characters("\t" + AutoPageNumberUtils.asAlphaNumeric(pageCount)); } else if (autoPageNumberFormat.equals("lower-alpha")){ xhtml.characters("\t" + AutoPageNumberUtils.asAlphaNumericLower(pageCount)); } } xhtml.endElement("div"); } } }
private void handleText(int length, InputStream stream, XHTMLContentHandler xhtml) throws IOException, SAXException, TikaException { byte[] str = new byte[length]; IOUtils.readFully(stream, str); if(str[length-1] != 0) { // Not properly null terminated, must be wrong return; } String text = extractText(str, false); xhtml.startElement("p"); xhtml.characters(text); xhtml.endElement("p"); }
protected static void parse(OldExcelExtractor extractor, XHTMLContentHandler xhtml) throws TikaException, IOException, SAXException { // Get the whole text, as a single string String text = extractor.getText(); // Split and output xhtml.startDocument(); String line; BufferedReader reader = new BufferedReader(new StringReader(text)); while ((line = reader.readLine()) != null) { xhtml.startElement("p"); xhtml.characters(line); xhtml.endElement("p"); } xhtml.endDocument(); }
attributes.addAttribute("", "", "cols", "CDATA", vecSize); xhtml.startElement("h3"); xhtml.characters(tableTitle); xhtml.endElement("h3"); xhtml.startElement("table", attributes); while ((line = reader.readLine()) != null) { xhtml.startElement("tr"); for (String val : line.split(" ")) { xhtml.startElement("td"); xhtml.characters(val); xhtml.endElement("td"); xhtml.endElement("tr"); xhtml.endElement("table");