TableFunctions.java 文件源码

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

项目:JATS2LaTeX 作者:
protected static void countColumns(XPath xPath, Table table, Node tableHead)
        throws XPathExpressionException, DOMException, NumberFormatException {
    if (tableHead != null) {
        Node firstRow = (Node) xPath.compile("*[1]").evaluate(tableHead, XPathConstants.NODE);
        NodeList childFirstRows = firstRow.getChildNodes();
        int columnNumber = 0;
        for (int w = 0; w < childFirstRows.getLength(); w++) {
            Node childFirstRow = childFirstRows.item(w);
            if (childFirstRow.getNodeValue() == null && (childFirstRow.getNodeName() == "th" || childFirstRow.getNodeName() == "td")) {
                int number = 1;
                if (childFirstRow.getAttributes().getNamedItem("colspan") != null) {
                    number = Integer.parseInt(childFirstRow.getAttributes().getNamedItem("colspan").getNodeValue());
                } 
                columnNumber = columnNumber + number;
            }
        }
        table.setColumnNumber(columnNumber);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号