TableFunctions.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:JATS2LaTeX 作者:
protected static void cellParsing(XPath xPath, Table table, Node tableHead, String rowType)
        throws XPathExpressionException, NumberFormatException, DOMException {
    if (tableHead != null) {
        NodeList trHeadNodes = (NodeList) xPath.compile("tr").evaluate(tableHead, XPathConstants.NODESET);
        for (int y = 0; y < trHeadNodes.getLength(); y++) {
            Row row = new Row();
            row.setType(rowType);
            table.getRow().add(row);
            NodeList cellNodes = (NodeList) xPath.compile("th|td").evaluate(trHeadNodes.item(y), XPathConstants.NODESET);
            for (int w = 0; w < cellNodes.getLength(); w++) {
                Cell cell = new Cell();
                row.getCell().add(cell);
                Node cellNode = cellNodes.item(w);
                if (cellNode != null && cellNode.getAttributes() != null) {
                    if (cellNode.getAttributes().getNamedItem("colspan") != null) {
                        cell.setColspan(Integer.parseInt(cellNode.getAttributes().getNamedItem("colspan").getNodeValue()));
                    } else {
                        cell.setColspan(1);
                    }
                    if (cellNode.getAttributes().getNamedItem("rowspan") != null) {
                        cell.setRowspan(Integer.parseInt(cellNode.getAttributes().getNamedItem("rowspan").getNodeValue()));
                    } else {
                        cell.setRowspan(1);
                    }
                    ParContent parContent = new ParContent();
                    parContent.setType("tableCell");
                    cell.getParContent().add(parContent);
                    Body.parsingParContent(cellNode, parContent);
                } 

            }

        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号