use of net.heartsome.xml.SAXBuilder 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.SAXBuilder 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.SAXBuilder 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