use of net.heartsome.cat.ts.ui.advanced.model.ElementBean in project translationstudio8 by heartsome.
the class ADXmlHandler method getconvertXmlElements.
/**
* 获取转换配置文件的所有内容
* @return ;
*/
public List<ElementBean> getconvertXmlElements(String xmlLocation) {
List<ElementBean> elementsList = new LinkedList<ElementBean>();
VTDNav vn = super.getVTDNav(xmlLocation);
AutoPilot ap = new AutoPilot(vn);
ElementBean bean;
try {
ap.selectXPath("/ini-file/tag");
while (ap.evalXPath() != -1) {
// 如果元素名与元素类型为空,那么当前节点不被添加
if (vn.getText() == -1 || vn.getAttrVal("hard-break") == -1 || "".equals(vn.toString(vn.getText())) || "".equals(vn.toString(vn.getAttrVal("hard-break")))) {
continue;
}
//开始添加元素名称
bean = new ElementBean();
bean.setName(vn.toString(vn.getText()));
bean.setType(vn.toString(vn.getAttrVal("hard-break")));
bean.setInlineType(vn.getAttrVal("ctype") != -1 ? vn.toString(vn.getAttrVal("ctype")) : "");
bean.setTransAttribute(vn.getAttrVal("attributes") != -1 ? vn.toString(vn.getAttrVal("attributes")) : "");
bean.setRemainSpace(vn.getAttrVal("keep-format") != -1 ? vn.toString(vn.getAttrVal("keep-format")) : "");
elementsList.add(bean);
}
} catch (Exception e) {
LOGGER.error("", e);
}
return elementsList;
}
use of net.heartsome.cat.ts.ui.advanced.model.ElementBean in project translationstudio8 by heartsome.
the class ADXmlHandler method getAnalysisXmlData.
/**
* 获取分析XML文件后的数据(针对于分析XML文件)
* @param xmlLocation
* @return ;
*/
public List<ElementBean> getAnalysisXmlData(String xmlLocation) {
List<ElementBean> beanList = new LinkedList<ElementBean>();
List<String> elementNameList = new ArrayList<String>();
VTDNav vn = getVTDNav(xmlLocation);
AutoPilot ap = new AutoPilot(vn);
ElementBean bean;
try {
ap.selectXPath("//*[text()!='' or not(./*)]");
while (ap.evalXPath() != -1) {
String elementName = vn.toString(vn.getCurrentIndex());
//如果元素名不重复,那么就添加到结果集中
if (elementNameList.indexOf(elementName) == -1) {
bean = new ElementBean();
bean.setName(elementName);
bean.setType("segment");
bean.setInlineType("");
bean.setTransAttribute("");
bean.setRemainSpace("");
beanList.add(bean);
elementNameList.add(elementName);
}
}
} catch (Exception e) {
LOGGER.error("", e);
}
return beanList;
}
use of net.heartsome.cat.ts.ui.advanced.model.ElementBean in project translationstudio8 by heartsome.
the class AddOrEditElementOfXmlConvertDialog method getElementBean.
public ElementBean getElementBean(String elementName) {
ElementBean bean;
Iterator<ElementBean> iter = elementsList.iterator();
while (iter.hasNext()) {
bean = iter.next();
if (elementName.equals(bean.getName())) {
return bean;
}
}
return null;
}
Aggregations