use of net.heartsome.xml.Catalogue in project translationstudio8 by heartsome.
the class PluginHelpDialog method loadTree.
private void loadTree(String helpFile) {
try {
tree.removeAll();
hashTable.clear();
File file = new File(helpFile);
String basePath = "";
if (!file.isAbsolute()) {
helpFile = file.getCanonicalPath();
file = new File(helpFile);
}
basePath = file.getParent();
currentFilePath = helpFile;
SAXBuilder builder = new SAXBuilder();
builder.setEntityResolver(new Catalogue(PluginUtil.getCataloguePath()));
Document document = builder.build(helpFile);
Element root = document.getRootElement();
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setText(root.getAttributeValue("title"));
getShell().setText(root.getAttributeValue("title"));
recurseTree(root, item, basePath);
item.setExpanded(true);
String url = root.getAttributeValue("url");
if (!url.equals("")) {
File f = new File(url);
if (!f.exists()) {
url = basePath + "/" + url;
}
browser.setUrl(new File(url).toURI().toURL().toString());
hashTable.put(item, url);
}
} catch (Exception e) {
}
}
use of net.heartsome.xml.Catalogue in project translationstudio8 by heartsome.
the class TBXTemplateUtil method loadTemplate.
private void loadTemplate(String catalogueFile) throws SAXException, ParserConfigurationException, IOException {
SAXBuilder builder = new SAXBuilder();
if (!catalogueFile.equals("")) {
//$NON-NLS-1$
Catalogue cat = new Catalogue(catalogueFile);
builder.setEntityResolver(cat);
builder.setValidating(true);
}
//$NON-NLS-1$
File templateFile = new File(templatePath, templateFileName);
document = builder.build(templateFile.getAbsolutePath());
Element tbxXCS = document.getRootElement();
//$NON-NLS-1$
Element datCatSet = tbxXCS.getChild("datCatSet");
if (datCatSet != null) {
List<Element> specs = datCatSet.getChildren();
Iterator<Element> specsIt = specs.iterator();
while (specsIt.hasNext()) {
Element spec = specsIt.next();
//$NON-NLS-1$
Element contents = spec.getChild("contents");
if (contents != null) {
items.add(spec);
}
}
}
}
use of net.heartsome.xml.Catalogue 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;
}
use of net.heartsome.xml.Catalogue in project translationstudio8 by heartsome.
the class Xliff2Resx method openXml.
/**
* Open xml.
* @param filename
* the filename
* @param catalogue
* the catalogue
* @return the document
* @throws Exception
* the exception
*/
private static Document openXml(String filename, String catalogue) throws Exception {
SAXBuilder builder = new SAXBuilder();
builder.setEntityResolver(new Catalogue(catalogue));
return builder.build(filename);
}
Aggregations