Example usage for org.dom4j Attribute getValue

List of usage examples for org.dom4j Attribute getValue

Introduction

In this page you can find the example usage for org.dom4j Attribute getValue.

Prototype

String getValue();

Source Link

Document

Returns the value of the attribute.

Usage

From source file:com.github.autoprimer3.SequenceFromDasUcsc.java

License:Open Source License

SequenceFromDasUcsc() {//get build names and DAS urls
    try {/*  w  w w .jav  a2  s  .  co m*/
        SAXReader reader = new SAXReader();
        URL url = new URL("http://genome.ucsc.edu/cgi-bin/das/dsn");//usa    
        //URL url = new URL("http://genome-euro.ucsc.edu/cgi-bin/das/dsn");    
        Document dasXml;
        dasXml = reader.read(url);
        Element root = dasXml.getRootElement();
        for (Iterator i = root.elementIterator("DSN"); i.hasNext();) {
            Element dsn = (Element) i.next();
            Element source = dsn.element("SOURCE");
            Attribute build = source.attribute("id");
            Element mapmaster = dsn.element("MAPMASTER");
            buildToMapMaster.put(build.getValue(), mapmaster.getText());
        }
    } catch (DocumentException | MalformedURLException ex) {
        //TO DO - handle (throw) this error properly
        ex.printStackTrace();
    }
}

From source file:com.glaf.core.xml.XmlBuilder.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void processForEachNode(Element element, Map<String, DatasetModel> dataSetMap,
        Map<String, Object> myDataMap, String systemName, Map<String, Object> params) {
    //LOG.debug("---------------------processForEachNode-----------------------");
    Element parent = element.getParent();
    String dsId = element.attributeValue("DataSetId");
    if (StringUtils.isNotEmpty(dsId)) {
        if (myDataMap != null && !myDataMap.isEmpty()) {
            params.putAll(myDataMap);//ww  w  .  java  2s.  c o m
        }
        DatasetModel dsm = dataSetMap.get(dsId);
        String sql = dsm.getSql();
        String queryId = dsm.getQueryId();
        List<Map<String, Object>> rows = null;
        if (StringUtils.isNotEmpty(queryId)) {
            Environment.setCurrentSystemName(systemName);
            List<Object> list = entityService.getList(queryId, params);
            if (list != null && !list.isEmpty()) {
                rows = new ArrayList<Map<String, Object>>();
                for (Object object : list) {
                    if (object instanceof Map) {
                        Map dataMap = (Map) object;
                        rows.add(dataMap);
                    } else {
                        try {
                            Map dataMap = BeanUtils.describe(object);
                            rows.add(dataMap);
                        } catch (Exception e) {
                        }
                    }
                }
            }
        } else if (StringUtils.isNotEmpty(sql)) {
            LOG.debug("sql:" + sql);
            LOG.debug("params:" + params);
            rows = queryHelper.getResultList(systemName, sql, params);
            // ITablePageService tablePageService =
            // ContextFactory.getBean("tablePageService");
            // rows = queryHelper.getResultList(systemName, sql, params);
            // Environment.setCurrentSystemName(systemName);
            // rows = tablePageService.getListData(sql, params);
            LOG.debug("#1 rows:" + rows.size());
        }
        if (rows != null && !rows.isEmpty()) {
            int sortNo = 0;
            List<?> elements = element.elements();
            if (elements != null && elements.size() == 1) {
                Element elem = (Element) elements.get(0);
                LOG.debug("name:" + elem.getName());
                for (Map<String, Object> dataMap : rows) {
                    sortNo = sortNo + 1;
                    dataMap.put("sortNo", sortNo);
                    Element e = elem.createCopy();
                    if (dsm.getControllers() != null && !dsm.getControllers().isEmpty()) {
                        List<FieldController> controllers = dsm.getControllers();
                        for (FieldController c : controllers) {
                            Class<?> x = ClassUtils.classForName(c.getProvider());
                            FieldConverter fp = (FieldConverter) ReflectUtils.newInstance(x);
                            fp.convert(c.getFromName(), c.getToName(), dataMap);
                        }
                    }

                    if (e.isTextOnly()) {
                        String value = e.getStringValue();
                        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
                            String text = QueryUtils.replaceBlankParas(value, dataMap);
                            e.setText(text);
                        }
                    }

                    List<?> attrs = e.attributes();
                    Iterator<?> iter = attrs.iterator();
                    while (iter.hasNext()) {
                        Attribute attr = (Attribute) iter.next();
                        String value = attr.getValue();
                        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
                            String text = QueryUtils.replaceBlankParas(value, dataMap);
                            attr.setValue(text);
                        }
                    }

                    e.setParent(null);
                    parent.add(e);
                }
            }
        }
    }

    parent.remove(element);

}

From source file:com.glaf.core.xml.XmlBuilder.java

License:Apache License

protected void processTextNode(Element element, Map<String, DatasetModel> dataSetMap,
        Map<String, Object> dataMap, String systemName, Map<String, Object> params) {
    //LOG.debug("---------------------processTextNode-----------------------");
    if (StringUtils.equals(element.getName(), "foreach")) {
        this.processForEachNode(element, dataSetMap, dataMap, systemName, params);
        return;/*from  w  w  w.j a va 2 s. co m*/
    }
    String dsId = element.attributeValue("DataSetId");
    if (StringUtils.isNotEmpty(dsId)) {
        if (dataMap != null && !dataMap.isEmpty()) {
            params.putAll(dataMap);
        }
        this.processNode(element, dataSetMap, systemName, params);
        return;
    }

    if (element.isTextOnly()) {
        String value = element.getStringValue();
        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
            String text = QueryUtils.replaceBlankParas(value, dataMap);
            element.setText(text);
        }
    }

    List<?> attrs = element.attributes();
    Iterator<?> iter = attrs.iterator();
    while (iter.hasNext()) {
        Attribute attr = (Attribute) iter.next();
        String value = attr.getValue();
        if (StringUtils.contains(value, "#{") && StringUtils.contains(value, "}")) {
            String text = QueryUtils.replaceBlankParas(value, dataMap);
            attr.setValue(text);
        }
    }

    List<?> elements = element.elements();
    Iterator<?> iterator = elements.iterator();
    while (iterator.hasNext()) {
        Element elem = (Element) iterator.next();
        if (StringUtils.equals(elem.getName(), "foreach")) {
            this.processForEachNode(elem, dataSetMap, dataMap, systemName, params);
        } else {
            String dsId2 = elem.attributeValue("DataSetId");
            if (StringUtils.isNotEmpty(dsId2)) {
                if (dataMap != null && !dataMap.isEmpty()) {
                    params.putAll(dataMap);
                }
                this.processNode(elem, dataSetMap, systemName, params);
            } else {
                this.processTextNode(elem, dataSetMap, dataMap, systemName, params);
            }
        }
    }
}

From source file:com.globalsight.everest.edit.offline.OfflineEditManagerLocal.java

License:Apache License

/**
 * Only when the source file is XLF, need re-wrap the off-line down-loaded
 * XLIFF file./*from  www. ja v  a2 s  .  co  m*/
 */
private void reWrapXliff(Document doc, HashSet<Long> jobIds) {
    Element root = doc.getRootElement();
    Element bodyElement = root.element(XliffConstants.FILE).element(XliffConstants.BODY);

    // Find TU elements that are from XLF source file.
    List<Element> xlfTuElements = new ArrayList<Element>();
    for (Iterator i = bodyElement.elementIterator(XliffConstants.TRANS_UNIT); i.hasNext();) {
        Element foo = (org.dom4j.Element) i.next();
        if (isSrcFileXlf(foo, jobIds)) {
            xlfTuElements.add(foo);
        }
    }

    if (xlfTuElements.size() == 0)
        return;

    //
    StringBuffer xliffString = new StringBuffer();
    xliffString.append("<?xml version=\"1.0\"?>");
    xliffString.append("<xliff version=\"1.2\">");
    xliffString.append("<file>");
    xliffString.append("<body>");
    Attribute stateAttr = null;
    ArrayList<String> trgStates = new ArrayList<String>();
    for (Element foo : xlfTuElements) {
        Element sourceElement = foo.element(XliffConstants.SOURCE);
        String sourceContent = sourceElement.asXML();
        sourceContent = sourceContent.replaceFirst("<" + XliffConstants.SOURCE + "[^>]*>", "");
        sourceContent = sourceContent.replace("</" + XliffConstants.SOURCE + ">", "");

        Element targetElement = foo.element(XliffConstants.TARGET);

        String targetContent = targetElement.asXML();
        targetContent = targetContent.replaceFirst("<" + XliffConstants.TARGET + "[^>]*>", "");
        targetContent = targetContent.replace("</" + XliffConstants.TARGET + ">", "");

        xliffString.append("<trans-unit>");
        xliffString.append("<source>").append(sourceContent).append("</source>");
        xliffString.append("<target>").append(targetContent).append("</target>");
        xliffString.append("</trans-unit>");

        // Store the state attributes in sequence
        stateAttr = targetElement.attribute(XliffConstants.STATE);
        if (stateAttr == null) {
            trgStates.add("");
        } else {
            trgStates.add(stateAttr.getValue());
        }
    }
    xliffString.append("</body>");
    xliffString.append("</file>");
    xliffString.append("</xliff>");

    // Extract it to get re-wrapped segments.
    DiplomatAPI api = new DiplomatAPI();
    api.setEncoding("UTF-8");
    api.setLocale(new Locale("en_US"));
    api.setInputFormat("xlf");
    api.setSentenceSegmentation(false);
    api.setSegmenterPreserveWhitespace(true);
    api.setSourceString(xliffString.toString());

    ArrayList<String> sourceArray = new ArrayList<String>();
    ArrayList<String> targetArray = new ArrayList<String>();

    try {
        api.extract();
        Output output = api.getOutput();

        for (Iterator it = output.documentElementIterator(); it.hasNext();) {
            DocumentElement element = (DocumentElement) it.next();

            if (element instanceof TranslatableElement) {
                TranslatableElement trans = (TranslatableElement) element;

                SegmentNode src = (SegmentNode) (trans.getSegments().get(0));
                if (trans.getXliffPartByName().equals("source")) {
                    sourceArray.add("<source>" + replaceEntity(src.getSegment()) + "</source>");
                } else if (trans.getXliffPartByName().equals("target")) {
                    targetArray.add("<target>" + replaceEntity(src.getSegment()) + "</target>");
                }
            }
        }
    } catch (Exception e) {
        if (s_category.isDebugEnabled()) {
            s_category.error(e.getMessage(), e);
        }
    }

    // Replace source/target elements
    int index = 0;
    if (sourceArray != null && targetArray != null) {
        for (Iterator i = bodyElement.elementIterator(XliffConstants.TRANS_UNIT); i.hasNext();) {
            if (index >= sourceArray.size()) {
                break;
            }

            Element foo = (org.dom4j.Element) i.next();
            if (!isSrcFileXlf(foo, jobIds)) {
                continue;
            }

            TuImpl tu = getTu(foo, jobIds);
            GxmlElement srcGxmlElement = tu.getSourceTuv().getGxmlElement();
            String newSrc = "<segment>" + GxmlUtil.stripRootTag(sourceArray.get(index)) + "</segment>";
            GxmlElement trgGxmlElement = SegmentUtil2.getGxmlElement(newSrc);
            newSrc = SegmentUtil2.adjustSegmentAttributeValues(srcGxmlElement, trgGxmlElement, "xlf");
            newSrc = "<source>" + GxmlUtil.stripRootTag(newSrc) + "</source>";
            Element sourceElement = foo.element(XliffConstants.SOURCE);
            Element newSourceElement = getDom(newSrc).getRootElement();
            foo.remove(sourceElement);
            foo.add(newSourceElement);

            String newTrg = "<segment>" + GxmlUtil.stripRootTag(targetArray.get(index)) + "</segment>";
            trgGxmlElement = SegmentUtil2.getGxmlElement(newTrg);
            newTrg = SegmentUtil2.adjustSegmentAttributeValues(srcGxmlElement, trgGxmlElement, "xlf");
            newTrg = "<target>" + GxmlUtil.stripRootTag(newTrg) + "</target>";
            Element newTargetElement = getDom(newTrg).getRootElement();
            Element targetElement = foo.element(XliffConstants.TARGET);
            foo.remove(targetElement);
            // If target has "state" attribute, it should be preserved.
            try {
                if (!"".equals(trgStates.get(index))) {
                    newTargetElement.add(new DefaultAttribute(XliffConstants.STATE, trgStates.get(index)));
                }
            } catch (Exception ignore) {

            }

            foo.add(newTargetElement);
            index++;
        }
    }
}

From source file:com.globalsight.everest.edit.offline.OfflineEditManagerLocal.java

License:Apache License

/**
 * Get "id" attribute from a "<trans-unit id="2328958" ...>".
 * //  w ww.jav a 2 s  .c o  m
 * @param tuElement
 * @return
 */
private String getTuId(Element tuElement) {
    Attribute tuIdAtt = tuElement.attribute("id");
    if (tuIdAtt != null) {
        return tuIdAtt.getValue();
    }
    return null;
}

From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java

License:Apache License

/**
 * Initialize toolSettings attributes' values.
 * //w  w w .ja  va 2 s .  c  o m
 * @param p_doc
 */
private void parseToolSettings(Element p_root) {
    if (p_root == null) {
        return;
    }

    try {
        Element ele = p_root.element(TTXConstants.FRONTMATTER).element(TTXConstants.TOOLSETTINGS);

        Attribute creationDateAtt = ele.attribute(TTXConstants.TOOLSETTINGS_ATT_CREATIONDATE);
        creationDate = (creationDateAtt == null ? "" : creationDateAtt.getValue());

        Attribute creationToolAtt = ele.attribute(TTXConstants.TOOLSETTINGS_ATT_CREATIONTOOL);
        creationTool = (creationToolAtt == null ? "" : creationToolAtt.getValue());

        Attribute creationToolVersionAtt = ele.attribute(TTXConstants.TOOLSETTINGS_ATT_CREATIONTOOLVERSION);
        creationToolVersion = (creationToolVersionAtt == null ? "" : creationToolVersionAtt.getValue());
    } catch (Exception e) {
        s_logger.error("Error occurs during parsing toolSettings.", e);
    }
}

From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java

License:Apache License

/**
 * Initialize userSettings attributes' values.
 * //w ww.ja  v  a 2s .  c  om
 * @param p_doc
 */
private void parseUserSettings(Element p_root) {
    if (p_root == null) {
        return;
    }

    try {
        Element ele = p_root.element(TTXConstants.FRONTMATTER).element(TTXConstants.USERSETTINGS);

        Attribute srcLangAtt = ele.attribute(TTXConstants.USERSETTINGS_SOURCE_lANGUAGE);
        sourceLanguage = (srcLangAtt == null ? "" : srcLangAtt.getValue());

        Attribute dataTypeAtt = ele.attribute(TTXConstants.USERSETTINGS_DATA_TYPE);
        dataType = (dataTypeAtt == null ? "" : dataTypeAtt.getValue());

        Attribute o_encodingAtt = ele.attribute(TTXConstants.USERSETTINGS_O_ENCODING);
        o_encoding = (o_encodingAtt == null ? "" : o_encodingAtt.getValue());

        Attribute trgLangAtt = ele.attribute(TTXConstants.USERSETTINGS_TARGET_LANGUAGE);
        targetLanguage = (trgLangAtt == null ? "" : trgLangAtt.getValue());

        Attribute srcDocumentPathAtt = ele.attribute(TTXConstants.USERSETTINGS_SOURCE_DOCUMENT_PATH);
        sourceDocumentPath = (srcDocumentPathAtt == null ? "" : srcDocumentPathAtt.getValue());

        Attribute userIdAtt = ele.attribute(TTXConstants.USERSETTINGS_USERID);
        userId = (userIdAtt == null ? "" : userIdAtt.getValue());

        Attribute dataTypeVersionAtt = ele.attribute(TTXConstants.USERSETTINGS_DATA_TYPE_VERSION);
        dataTypeVersion = (dataTypeVersionAtt == null ? "" : dataTypeVersionAtt.getValue());

        Attribute settingsPathAtt = ele.attribute(TTXConstants.USERSETTINGS_SETTINGS_PATH);
        settingsPath = (settingsPathAtt == null ? "" : settingsPathAtt.getValue());

        Attribute settingsNameAtt = ele.attribute(TTXConstants.USERSETTINGS_SETTINGS_NAME);
        settingsname = (settingsNameAtt == null ? "" : settingsNameAtt.getValue());

        Attribute trgDefaultFontAtt = ele.attribute(TTXConstants.USERSETTINGS_TARGET_DEFAULT_FONT);
        targetDefaultFont = (trgDefaultFontAtt == null ? "" : trgDefaultFontAtt.getValue());
    } catch (Exception e) {
        s_logger.error("Error occurs duing parsing userSettings.", e);
    }
}

From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java

License:Apache License

/**
 * Parse extra info for uploading such as "pageId", "taskId" etc.
 * // w w w  .j  a v a 2 s .c  om
 * @param p_rawElement
 */
private void parseHeaderInfo(Element p_rawElement) {
    if (p_rawElement == null) {
        return;
    }

    Iterator utIt = p_rawElement.elementIterator(TTXConstants.UT);
    while (utIt.hasNext()) {
        Element utEle = (Element) utIt.next();
        Attribute displayTextAtt = utEle.attribute(TTXConstants.UT_ATT_DISPLAYTEXT);
        if (displayTextAtt != null) {
            String attValue = displayTextAtt.getValue();
            // ignore locked segment - UT gs:locked segment
            if (TTXConstants.GS_LOCKED_SEGMENT.equalsIgnoreCase(attValue)) {
                continue;
            }

            String utTextNodeValue = utEle.getStringValue();
            int index = utTextNodeValue.lastIndexOf(":");
            if (index == -1) {
                continue;
            }
            String utName = utTextNodeValue.substring(0, index).trim();
            String utValue = utTextNodeValue.substring(index + 1).trim();
            if (TTXConstants.GS_ENCODING.equalsIgnoreCase(attValue) || "Encoding".equalsIgnoreCase(utName)) {
                gs_Encoding = utValue;
            } else if (TTXConstants.GS_DOCUMENT_FORMAT.equalsIgnoreCase(attValue)
                    || "Document Format".equalsIgnoreCase(utName)) {
                gs_DocumentFormat = utValue;
            } else if (TTXConstants.GS_PLACEHOLDER_FORMAT.equalsIgnoreCase(attValue)
                    || "Placeholder Format".equalsIgnoreCase(utName)) {
                gs_PlaceholderFormat = utValue;
            } else if (TTXConstants.GS_SOURCE_LOCALE.equalsIgnoreCase(attValue)
                    || "Source Locale".equalsIgnoreCase(utName)) {
                gs_SourceLocale = utValue;
            } else if (TTXConstants.GS_TARGET_LOCALE.equalsIgnoreCase(attValue)
                    || "Target Locale".equalsIgnoreCase(utName)) {
                gs_TargetLocale = utValue;
            } else if (TTXConstants.GS_PAGEID.equalsIgnoreCase(attValue)
                    || "Page ID".equalsIgnoreCase(utName)) {
                gs_PageID = utValue;
            } else if (TTXConstants.GS_WORKFLOW_ID.equalsIgnoreCase(attValue)
                    || "Workflow ID".equalsIgnoreCase(utName)) {
                gs_WorkflowID = utValue;
            } else if (TTXConstants.GS_TASK_ID.equalsIgnoreCase(attValue)
                    || "Task ID".equalsIgnoreCase(utName)) {
                gs_TaskID = utValue;
            } else if (TTXConstants.GS_EXACT_MATCH_WORD_COUNT.equalsIgnoreCase(attValue)
                    || "Exact Match word count".equalsIgnoreCase(utName)) {
                gs_ExactMatchWordCount = utValue;
            } else if (TTXConstants.GS_FUZZY_MATCH_WORD_COUNT.equalsIgnoreCase(attValue)
                    || "Fuzzy Match word count".equalsIgnoreCase(utName)) {
                gs_FuzzyMatchWordCount = utValue;
            } else if (TTXConstants.GS_EDIT_ALL.equalsIgnoreCase(attValue)
                    || "Edit all".equalsIgnoreCase(utName)) {
                gs_EditAll = utValue;
            } else if (TTXConstants.GS_POPULATE_100_TARGET_SEGMENTS.equals(attValue)
                    || "Populate 100% Target Segments".equalsIgnoreCase(utName)) {
                gs_Populate100TargetSegments = utValue;
            }
        }
    }
}

From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java

License:Apache License

private void elementNodeProcessor(Node p_node, boolean p_isSource) {
    Element element = (Element) p_node;
    String eleStr = element.asXML();
    String elementName = element.getName();

    boolean isHeaderInfoUT = false;
    boolean isTuId = false;
    if (TTXConstants.TU.equalsIgnoreCase(elementName) || (element.getParent() != null
            && TTXConstants.TUV.equalsIgnoreCase(element.getParent().getName()))) {
        // latestPosition = TTXConstants.IN_TU;
    } else if (TTXConstants.UT.equalsIgnoreCase(elementName)) {
        Attribute att = element.attribute(TTXConstants.UT_ATT_DISPLAYTEXT);
        if (att != null) {
            String value = att.getValue();
            // If header info,return as header info has been handled
            // separately.
            // This check is not required.
            isHeaderInfoUT = isHeaderInfo(value);
            if (isHeaderInfoUT) {
                return;
            }/*  ww w  .j  ava  2s  . co m*/
            // If TuId,handle them here.
            isTuId = isTuId(value);
            if (isTuId) {
                // latestPosition = TTXConstants.TU_ID;
                String tuId = value.substring(value.indexOf(":") + 1).trim();
                if (results != null && results.length() > 0) {
                    results.append(TTXConstants.NEW_LINE).append(TTXConstants.NEW_LINE);
                }
                results.append(TTXConstants.HASH_MARK).append(tuId).append(TTXConstants.NEW_LINE);

                return;
            }
        }
    }

    if (element.nodeCount() > 0) {
        Iterator nodesIt = element.nodeIterator();
        while (nodesIt.hasNext()) {
            Node node = (Node) nodesIt.next();
            String nodeStr = node.asXML();
            String nodeName = node.getName();
            if (TTXConstants.TUV.equalsIgnoreCase(node.getName())) {
                Attribute langAtt = ((Element) node).attribute(TTXConstants.TUV_ATT_LANG);
                String lang = null;
                if (langAtt != null) {
                    lang = langAtt.getValue();
                }
                if (sourceLanguage != null && sourceLanguage.equals(lang)) {
                    // latestPosition = TTXConstants.IN_SOURCE_TUV;
                    // Not handle source TUV for TTX off-line uploading.
                    // domNodehandler(node, true);
                } else {
                    // latestPosition = TTXConstants.IN_TARGET_TUV;
                    domNodehandler(node, false);
                }
            } else {
                domNodehandler(node, false);
            }
        }
    } else {
        if (TTXConstants.UT.equalsIgnoreCase(elementName)) {
            Attribute displayTextAtt = element.attribute(TTXConstants.UT_ATT_DISPLAYTEXT);
            if (displayTextAtt != null) {
                String attValue = displayTextAtt.getValue();
                if (attValue != null && attValue.startsWith(TTXConstants.TU_ID)) {
                    // latestPosition = TTXConstants.TU_ID;
                    String tuId = attValue.substring(attValue.indexOf(":") + 1).trim();
                    if (results != null && results.length() > 0) {
                        results.append(TTXConstants.NEW_LINE).append(TTXConstants.NEW_LINE);
                    }
                    results.append(TTXConstants.HASH_MARK).append(tuId).append(TTXConstants.NEW_LINE);
                } else if (attValue != null && attValue.startsWith(TTXConstants.GS)) {
                    Attribute typeValueAtt = element.attribute(TTXConstants.UT_ATT_TYPE);
                    String typeValue = null;
                    if (typeValueAtt != null) {
                        typeValue = typeValueAtt.getValue();
                    }

                    String gsTag = attValue.substring(attValue.indexOf(":") + 1).trim();
                    if (typeValue != null && TTXConstants.UT_ATT_TYPE_START.equalsIgnoreCase(typeValue)) {
                        results.append("[").append(gsTag).append("]");
                    } else if (typeValue != null && TTXConstants.UT_ATT_TYPE_END.equalsIgnoreCase(typeValue)) {
                        results.append("[/").append(gsTag).append("]");
                    } else {
                        results.append("[").append(gsTag).append("]");
                        results.append("[/").append(gsTag).append("]");
                    }
                }
            }
        } else if (TTXConstants.DF.equalsIgnoreCase(elementName)) {
            // do not handle this.
        }
    }
}

From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java

License:Apache License

/**
 * Judge if current node is in target TUV element.
 * // w w  w .  ja  va2s. c om
 * @param p_node
 * @return
 */
private boolean isInTargetTuv(Node p_node) {
    boolean result = false;
    if (p_node == null) {
        return false;
    }

    Element parentNode = p_node.getParent();
    while (parentNode != null) {
        // In Tuv.
        String nodeName = parentNode.getName();
        if ("Tuv".equalsIgnoreCase(nodeName)) {
            Attribute langAtt = parentNode.attribute(TTXConstants.TUV_ATT_LANG);
            String attName = langAtt.getValue();
            if (langAtt != null && targetLanguage.equalsIgnoreCase(attName)) {
                result = true;
            }

            break;
        }

        parentNode = parentNode.getParent();
    }

    return result;
}