use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class XLFHandler method getTgtContent.
/**
* 得到目标的完整内容
* @param rowId
* 行的唯一标识
* @return 目标的完整内容;
*/
public String getTgtContent(String rowId) {
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId);
VTDNav vn = getVTDNavByRowId(rowId);
try {
VTDUtils vu = new VTDUtils(vn);
return vu.getValue(tuXPath + "/target/text()");
} catch (NavException e) {
LOGGER.error("", e);
e.printStackTrace();
}
return null;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class XLFHandler method getCaseTgtContent.
/** burke 为修改锁定行目标文本不能修改其大小写添加 getCaseTgtContent方法 */
/**
* 获取要改变大小写的target中的文本内容
* @param rowId
* @return
*/
public String getCaseTgtContent(String rowId) {
AutoPilot ap = new AutoPilot();
VTDNav vn = null;
vn = getVTDNavByRowId(rowId);
ap.bind(vn);
try {
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId);
ap.selectXPath(tuXPath);
if (ap.evalXPath() != -1) {
int attrIndex = vn.getAttrVal("translate");
if (attrIndex != -1) {
String attrValue = vn.toString(attrIndex);
if (attrValue.equals("no")) {
return "no";
}
}
}
ap.resetXPath();
} catch (XPathEvalException e) {
LOGGER.error("", e);
e.printStackTrace();
} catch (NavException e) {
LOGGER.error("", e);
e.printStackTrace();
} catch (XPathParseException e) {
LOGGER.error("", e);
e.printStackTrace();
}
String tgt = getTgtContent(rowId);
return tgt;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class XLFHandler method getSrcPureText.
/**
* 得到源的纯文本内容
* @param rowId
* 行的唯一标识
* @return 源的纯文本内容;
*/
public String getSrcPureText(String rowId) {
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId);
VTDNav vn = getVTDNavByRowId(rowId);
try {
VTDUtils vu = new VTDUtils(vn);
vn.push();
vu.pilot(tuXPath + "/source");
String result = getTUPureText(vu.getVTDNav());
vn.pop();
return result;
} catch (NavException e) {
LOGGER.error("", e);
e.printStackTrace();
}
return null;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class ProjectConfiger method save.
/**
* 保存文件
* @param xm
* XMLModifier对象
* @param fileName
* 文件名
* @return 是否保存成功;
*/
private boolean save(XMLModifier xm, File file) {
try {
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
// 写入文件
xm.output(bos);
bos.close();
fos.close();
VTDGen vg = new VTDGen();
try {
if (vg.parseFile(projCfgFile.getPath(), true)) {
vu.bind(vg.getNav());
} else {
throw new ParseException();
}
} catch (NavException e) {
logger.error("", e);
} catch (ParseException e) {
logger.error("", e);
}
return true;
} catch (ModifyException e) {
logger.error("", e);
e.printStackTrace();
} catch (TranscodeException e) {
logger.error("", e);
e.printStackTrace();
} catch (IOException e) {
logger.error("", e);
e.printStackTrace();
}
return false;
}
use of com.ximpleware.NavException in project translationstudio8 by heartsome.
the class ProjectConfiger method getCurrentProjectConfig.
/**
* 获取项目配置信息
* @return 指定项目配置文件中的所有信息;
*/
public ProjectInfoBean getCurrentProjectConfig() {
ProjectInfoBean bean = new ProjectInfoBean();
vu.getVTDNav().push();
AutoPilot hsAp = new AutoPilot(vu.getVTDNav());
try {
hsAp.selectXPath("/projectDescription/hs");
if (hsAp.evalXPath() != -1) {
bean.setProjectName(getProjectName());
bean.setMapField(getFieldMap());
bean.setMapAttr(getAttrMap());
bean.setSourceLang(getSourceLanguage());
bean.setTargetLang(getTargetlanguages());
bean.setTmDb(getAllTmDbs());
bean.setTbDb(getTermBaseDbs(false));
}
} catch (XPathParseException e) {
logger.error("", e);
} catch (XPathEvalException e) {
logger.error("", e);
} catch (NavException e) {
logger.error("", e);
}
vu.getVTDNav().pop();
return bean;
}
Aggregations