Search in sources :

Example 16 with Element

use of net.heartsome.xml.Element in project translationstudio8 by heartsome.

the class TBXTemplateUtil method getTemplateFiles.

public static Vector<String> getTemplateFiles(String catalogueFile, String templatePath, boolean needArray) {
    Vector<String> result = new Vector<String>();
    File templateDir = new File(templatePath);
    String[] contents = templateDir.list();
    if (contents != null) {
        for (int i = 0; i < contents.length; i++) {
            File currentFile = new File(templateDir.getAbsolutePath(), contents[i]);
            if (currentFile.isFile()) {
                try {
                    SAXBuilder builder = new SAXBuilder();
                    if (!catalogueFile.equals("")) {
                        //$NON-NLS-1$
                        Catalogue cat = new Catalogue(catalogueFile);
                        builder.setEntityResolver(cat);
                    }
                    Document doc = builder.build(currentFile.getAbsolutePath());
                    Element tbxXCS = doc.getRootElement();
                    //$NON-NLS-1$
                    Element datCatSet = tbxXCS.getChild("datCatSet");
                    if (datCatSet != null) {
                        result.add(currentFile.getName());
                    }
                } catch (Exception e) {
                    LOGGER.error("", e);
                }
            }
        }
    }
    return result;
}
Also used : Catalogue(net.heartsome.xml.Catalogue) SAXBuilder(net.heartsome.xml.SAXBuilder) Element(net.heartsome.xml.Element) Document(net.heartsome.xml.Document) Vector(java.util.Vector) File(java.io.File) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 17 with Element

use of net.heartsome.xml.Element in project translationstudio8 by heartsome.

the class TBXTemplateUtil method getItemDescription.

public String getItemDescription(int item) {
    Element spec = items.get(item);
    //$NON-NLS-1$
    String itemDesc = spec.getAttributeValue("display");
    if (itemDesc.equals("")) {
        //$NON-NLS-1$
        return getItemName(item);
    }
    return itemDesc;
}
Also used : Element(net.heartsome.xml.Element)

Example 18 with Element

use of net.heartsome.xml.Element in project translationstudio8 by heartsome.

the class ReverseConversionValidateWithLibrary3 method createList.

/**
	 * 创建翻译节点列表
	 * @param rootPara
	 *            ;
	 */
private void createList(Element rootPara) {
    List<Element> files = rootPara.getChildren();
    Iterator<Element> it = files.iterator();
    while (it.hasNext()) {
        Element el = it.next();
        if (el.getName().equals("trans-unit")) {
            //$NON-NLS-1$
            segments.add(el);
        } else {
            createList(el);
        }
    }
}
Also used : Element(net.heartsome.xml.Element)

Aggregations

Element (net.heartsome.xml.Element)18 File (java.io.File)8 Catalogue (net.heartsome.xml.Catalogue)7 SAXBuilder (net.heartsome.xml.SAXBuilder)7 Document (net.heartsome.xml.Document)5 Node (org.w3c.dom.Node)5 FileOutputStream (java.io.FileOutputStream)4 Vector (java.util.Vector)3 IOException (java.io.IOException)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 XMLOutputter (net.heartsome.xml.XMLOutputter)2 TreeItem (org.eclipse.swt.widgets.TreeItem)2 SAXException (org.xml.sax.SAXException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URL (java.net.URL)1 IFile (org.eclipse.core.resources.IFile)1