Example usage for org.dom4j Element nodeCount

List of usage examples for org.dom4j Element nodeCount

Introduction

In this page you can find the example usage for org.dom4j Element nodeCount.

Prototype

int nodeCount();

Source Link

Document

Returns the number of Node instances that this branch contains.

Usage

From source file:com.globalsight.everest.projecthandler.ProjectTmTuvT.java

License:Apache License

private void findHiElements(ArrayList p_result, Element p_element) {
    // Depth-first traversal: add embedded <hi> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findHiElements(p_result, (Element) child);
        }/*from  w ww  .  j a v  a 2s  .  c  om*/
    }

    if (p_element.getName().equals("hi")) {
        p_result.add(p_element);
    }
}

From source file:com.globalsight.everest.tm.exporter.TmxWriter.java

License:Apache License

private static void findSubElements(ArrayList p_result, Element p_element) {
    // Depth-first traversal: add embedded <sub> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findSubElements(p_result, (Element) child);
        }/*from   ww  w .jav  a 2s . co  m*/
    }

    if (p_element.getName().equals("sub")) {
        p_result.add(p_element);
    }
}

From source file:com.globalsight.everest.tm.exporter.TmxWriter.java

License:Apache License

private static void findNbspElements(ArrayList p_result, Element p_element) {
    // Depth-first traversal: add embedded <ph x-nbspace> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findNbspElements(p_result, (Element) child);
        }/*  ww  w. ja v  a  2s . c  o m*/
    }

    if (p_element.getName().equals("ph")) {
        String attr = p_element.attributeValue("type");

        if (attr != null && attr.equals("x-nbspace")) {
            p_result.add(p_element);
        }
    }
}

From source file:com.globalsight.everest.tm.exporter.TmxWriter.java

License:Apache License

/**
 * Finds elements bearing an "x" element. These are bpt (required) and it,
 * ph, hi (optional)./*from w w  w. j av a2  s . com*/
 */
private void findElementsWithX(ArrayList p_result, Element p_element) {
    // Prefix-traversal
    if (p_element.attributeValue("x") != null) {
        p_result.add(p_element);
    }

    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findElementsWithX(p_result, (Element) child);
        }
    }
}

From source file:com.globalsight.everest.tm.exporter.TmxWriter.java

License:Apache License

private static void injectStandardFormattingCodes(Element p_root, Element p_element) {
    // Depth-first traversal: add embedded <sub> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            injectStandardFormattingCodes(p_root, (Element) child);
        }//ww w  .  ja  va 2 s  . c  o  m
    }

    String tagName = p_element.getName();
    String typeAttr = p_element.attributeValue("type");
    String iAttr = p_element.attributeValue("i");
    String posAttr = p_element.attributeValue("pos");

    if (tagName.equals("bpt") && typeAttr != null && iAttr != null) {
        Element ept = (Element) p_root.selectSingleNode("//ept[@i='" + iAttr + "']");

        if (typeAttr.equals("bold")) {
            p_element.addText("<B>");
            ept.addText("</B>");
        } else if (typeAttr.equals("italic")) {
            p_element.addText("<I>");
            ept.addText("</I>");
        } else if (typeAttr.equals("ulined")) {
            p_element.addText("<U>");
            ept.addText("</U>");
        }
    } else if (tagName.equals("it") && typeAttr != null && posAttr != null) {
        if (typeAttr.equals("bold")) {
            if (posAttr.equals("begin")) {
                p_element.addText("<B>");
            } else {
                p_element.addText("</B>");
            }
        } else if (typeAttr.equals("italic")) {
            if (posAttr.equals("begin")) {
                p_element.addText("<I>");
            } else {
                p_element.addText("</I>");
            }
        } else if (typeAttr.equals("ulined")) {
            if (posAttr.equals("begin")) {
                p_element.addText("<U>");
            } else {
                p_element.addText("</U>");
            }
        }
    }
}

From source file:com.globalsight.everest.tm.importer.TmxReaderThread.java

License:Apache License

private void findSubElements(ArrayList p_result, Element p_element) {
    // Depth-first traversal: add embedded <sub> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findSubElements(p_result, (Element) child);
        }/*  w ww  .  ja va2 s.c  o  m*/
    }

    if (p_element.getName().equals("sub")) {
        p_result.add(p_element);
    }
}

From source file:com.globalsight.everest.tm.util.TmxLevelSplitter.java

License:Apache License

public boolean containsTags2(Element p_seg) {
    for (int i = 0, max = p_seg.nodeCount(); i < max; i++) {
        Node child = (Node) p_seg.node(i);

        if (child instanceof Element) {
            return true;
        }/*www . java  2 s .c o  m*/
    }

    return false;
}

From source file:com.globalsight.everest.tm.util.trados.TradosHtmlTmxToGxml.java

License:Apache License

private void findUtElements(ArrayList p_result, Element p_element) {
    // Depth-first traversal: add embedded <ut> to the list first.
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findUtElements(p_result, (Element) child);
        }//w  w w  . j a v a  2  s.  co  m
    }

    if (p_element.getName().equals("ut")) {
        p_result.add(p_element);
    }
}

From source file:com.globalsight.everest.tm.util.ttx.TtxClean.java

License:Apache License

private void findNonTuElements(ArrayList p_result, Element p_element) {
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findNonTuElements(p_result, (Element) child);
        }/*from w  w  w.  ja v a2 s  .  com*/
    }

    String name = p_element.getName();

    if (!name.equals(Ttx.TU) && !name.equals(Ttx.TUV) && !name.equals(Ttx.RAW)) {
        p_result.add(p_element);
    }
}

From source file:com.globalsight.everest.tm.util.ttx.TtxClean.java

License:Apache License

private void findTuElements(ArrayList p_result, Element p_element) {
    for (int i = 0, max = p_element.nodeCount(); i < max; i++) {
        Node child = (Node) p_element.node(i);

        if (child instanceof Element) {
            findTuElements(p_result, (Element) child);
        }/*from w  w w. java2  s .  c  o m*/
    }

    String name = p_element.getName();

    if (name.equals(Ttx.TU)) {
        p_result.add(p_element);
    }
}