@Override public void startBookmark(String id, String name) { //skip bookmarks within hyperlinks if (name != null && ! wroteHyperlinkStart) { try { xhtml.startElement("a", "name", name); xhtml.endElement("a"); } catch (SAXException e) { } } }
private void writeKeyword(String keyword) throws SAXException { xhtml.startElement("span", "class", "java-keyword"); xhtml.characters(keyword); xhtml.endElement("span"); }
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 startRow(int rowNum) { try { // Missing rows, if desired, with a single empty row if (includeMissingRows && rowNum > (lastSeenRow+1)) { for (int rn=lastSeenRow+1; rn<rowNum; rn++) { xhtml.startElement("tr"); xhtml.startElement("td"); xhtml.endElement("td"); xhtml.endElement("tr"); } } // Start the new row xhtml.startElement("tr"); lastSeenCol = -1; } catch (SAXException e) { } }
xhtml.startElement("pre"); xhtml.characters(" " + packageName + ";\n"); xhtml.characters("{\n"); } catch (SAXException e) { throw new RuntimeException(e);
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"); }
@Override public void embeddedOLERef(String relId) { if (relId == null) { return; } try { AttributesImpl attributes = new AttributesImpl(); attributes.addAttribute("", "class", "class", "CDATA", "embedded"); attributes.addAttribute("", "id", "id", "CDATA", relId); xhtml.startElement("div", attributes); xhtml.endElement("div"); } catch (SAXException 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"); } }
@Override public void embeddedPicRef(String picFileName, String picDescription) { try { AttributesImpl attr = new AttributesImpl(); if (picFileName != null) { attr.addAttribute("", "src", "src", "CDATA", "embedded:" + picFileName); } if (picDescription != null) { attr.addAttribute("", "alt", "alt", "CDATA", picDescription); } xhtml.startElement("img", attr); xhtml.endElement("img"); } catch (SAXException 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); } }
private void outputTable(String idRef) throws SAXException { List<List<String>> tableData = this.tableData.get(idRef); if (tableData != null) { xhtml.startElement("table"); for (List<String> row : tableData) { xhtml.startElement("tr"); for (String cell : row) { xhtml.element("td", cell); } xhtml.endElement("tr"); } xhtml.endElement("table"); } }
xhml.startElement(P); for (GlyphRun run : row) { xhml.characters(run.unicodeString); xhml.endElement(P);
private void processExtraText() throws SAXException { if (extraTextCells.size() > 0) { for (Cell cell : extraTextCells) { handler.startElement("div", "class", "outside"); cell.render(handler); handler.endElement("div"); } // Reset extraTextCells.clear(); } }
/** * 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"); }
private void parseTableData(String value) throws SAXException { if (currentColumn == 0) { xhtml.startElement("tr"); } xhtml.element("td", value); if (currentColumn.equals(numberOfColumns)) { xhtml.endElement("tr"); } }
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); }
public void render(XHTMLContentHandler handler) throws SAXException { handler.startElement("a", "href", link); super.render(handler); handler.endElement("a"); }
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");
/** * Outputs a section of text if the given text is non-empty. * * @param xhtml XHTML content handler * @param section the class of the <div/> section emitted * @param text text to be emitted, if any * @throws SAXException if an error occurs */ private void addTextIfAny( XHTMLContentHandler xhtml, String section, String text) throws SAXException { if (text != null && text.length() > 0) { xhtml.startElement("div", "class", section); xhtml.element("p", text); xhtml.endElement("div"); } }