Example usage for org.dom4j Element node

List of usage examples for org.dom4j Element node

Introduction

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

Prototype

Node node(int index) throws IndexOutOfBoundsException;

Source Link

Document

Returns the Node at the specified index position.

Usage

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).//ww  w .  j a  v  a2  s .  c  om
 */
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 .jav  a 2s  .  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);
        }//from   w ww .ja  va 2 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;
        }/*from   ww w .ja  v  a2  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  .  ja  va 2 s .c  o  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  ww w .  ja v a 2s.  c om
    }

    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   ww  w.  ja  va  2 s  .  c o m
    }

    String name = p_element.getName();

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

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

License:Apache License

/**
 * Finds TTX formatting elements (DF).//from w w w  .  j  a v a 2  s . co  m
 */
private void findDfElements(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) {
            findDfElements(p_result, (Element) child);
        }
    }

    String name = p_element.getName();

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

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

License:Apache License

/**
 * Finds TTX/TMX unknown tag elements (UT).
 */// w w  w.jav a  2 s .  c o m
private void findUtElements(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) {
            findUtElements(p_result, (Element) child);
        }
    }

    String name = p_element.getName();

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

From source file:com.globalsight.ling.docproc.DiplomatWordCounter.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);
        }/*from   www  .  j av a 2  s.  c om*/
    }

    if (p_element.getName().equals(DiplomatNames.Element.SUB)) {
        p_result.add(p_element);
    }
}