本文整理汇总了Java中com.ximpleware.XPathParseException类的典型用法代码示例。如果您正苦于以下问题:Java XPathParseException类的具体用法?Java XPathParseException怎么用?Java XPathParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XPathParseException类属于com.ximpleware包,在下文中一共展示了XPathParseException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: approveTransUnits
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 批准或取消批准指定Id的翻译单元
* @param rowIdList
* 要修改的翻译单元Id的集合;
* @param approve
* true:批准;false:取消批准;
* @throws XliffException
*/
public List<String> approveTransUnits(List<String> rowIdList, final boolean approve, final boolean checkTargetWidth) {
if (rowIdList == null || rowIdList.isEmpty()) {
return Collections.<String> emptyList();
}
final ArrayList<String> list = new ArrayList<String>();
handleSomeSegment(rowIdList, new PerSegmentHandler() {
public void handle(String rowId, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws XPathParseException,
XPathEvalException, NavException, ModifyException, UnsupportedEncodingException {
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId); // 根据RowId得到定位到该翻译单元的XPath
if (vu.pilot(ap, tuXPath) != -1) {
String approvedValue = approve ? "yes" : "no";
changeApproveProp(vu.getVTDNav(), approvedValue, xm);
}
}
});
return list;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:XLFHandler.java
示例2: getTransUnitInfo
import com.ximpleware.XPathParseException; //导入依赖的package包/类
private TransUnitInfo2TranslationBean getTransUnitInfo(VTDUtils vu) throws XPathParseException, XPathEvalException,
NavException {
TransUnitInfo2TranslationBean tuInfo = new TransUnitInfo2TranslationBean();
vu.getVTDNav().push();
AutoPilot sourceAp = new AutoPilot(vu.getVTDNav());
sourceAp.selectXPath("./source");
String fullText = "";
String pureText = "";
if (sourceAp.evalXPath() != -1) {
fullText = vu.getElementContent();
pureText = xlfHandler.getTUPureText(vu.getVTDNav());
}
vu.getVTDNav().pop();
if (fullText == null || fullText.equals("") || pureText.equals("")) {
return null;
}
tuInfo.setSrcFullText(fullText);
tuInfo.setSrcPureText(pureText);
return tuInfo;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:PreMachineTranslation.java
示例3: changeTranslateProp
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 改变translate属性的值
* @param translateValue
* 可选值:“yes”、“no”
* @param xm
* XMLModifier对象;
* @throws NavException
* @throws UnsupportedEncodingException
* @throws ModifyException
* @throws XPathParseException
* @throws XPathEvalException
*/
private boolean changeTranslateProp(VTDNav vn, String translateValue, XMLModifier xm) throws NavException,
ModifyException, UnsupportedEncodingException, XPathParseException, XPathEvalException {
if (translateValue == null) {
return false;
}
vn.push();
boolean isChanged = false; // 当前的TransUnit的translate属性是否执行了修改
int attrIdx = vn.getAttrVal("translate");
if (attrIdx != -1) { // 存在translate属性
String translate = vn.toString(attrIdx);
if (!translate.equals(translateValue)) { // translate属性值不为指定的translateValue
xm.updateToken(attrIdx, translateValue);
isChanged = true;
}
} else {
xm.insertAttribute(" translate=\"" + translateValue + "\" ");
if (translateValue.equals("no")) { // 默认值为yes
isChanged = true;
}
}
vn.pop();
return isChanged;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:37,代码来源:XLFHandler.java
示例4: deleteAltTrans
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 删除匹配
* @param rowIds
* 行的唯一标识集合;
*/
public void deleteAltTrans(List<String> rowIds) {
handleSomeSegment(rowIds, new PerSegmentHandler() {
public void handle(String rowId, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws XPathParseException,
XPathEvalException, NavException, ModifyException {
String tuXPath = RowIdUtil.parseRowIdToXPath(rowId); // 根据RowId得到定位到该翻译单元的XPath
// vu.delete(ap, xm, tuXPath + "/alt-trans", VTDUtils.PILOT_TO_END);
if (vu.pilot(ap, tuXPath) == -1) {
return;
}
ap.selectXPath("./alt-trans");
while (ap.evalXPath() != -1) {
xm.remove();
}
}
});
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:XLFHandler.java
示例5: getCurrentElementAttributs
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 获取所有当前元素节点的全部属性。如果当前节点没有属性,返回 null。
* @param nsPrefix
* 需声明的名空间前缀,可与XML文件实际前缀不同。
* @param nsUrl
* 需声明的名空间地址,必须与 XML 文件中声明的地址一致。
* @exception XPathEvalException
* ,XPathParseException,NavException
*/
public Hashtable<String, String> getCurrentElementAttributs(String nsPrefix, String nsUrl)
throws XPathParseException, XPathEvalException, NavException {
Hashtable<String, String> attributes = new Hashtable<String, String>();
AutoPilot apAttributes = new AutoPilot(vn);
apAttributes.declareXPathNameSpace(nsPrefix, nsUrl);
apAttributes.selectXPath("@*");
int inx = -1;
while ((inx = apAttributes.evalXPath()) != -1) {
String name = vn.toString(inx);
inx = vn.getAttrVal(name);
String value = inx != -1 ? vn.toString(inx) : "";
attributes.put(name, value);
}
apAttributes.resetXPath();
if (attributes.isEmpty()) {
attributes = null;
}
return attributes;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:31,代码来源:VTDUtils.java
示例6: getNotes
import com.ximpleware.XPathParseException; //导入依赖的package包/类
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
Vector<NoteBean> notes = new Vector<NoteBean>();
VTDNav vn = vu.getVTDNav();
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace("xml", VTDUtils.XML_NAMESPACE_URL);
ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
ap.selectXPath("./note");
while (ap.evalXPath() != -1) {
NoteBean note = new NoteBean(vu.getElementContent());
note.setLang(vu.getCurrentElementAttribut("xml:lang", null));
note.setFrom(vu.getCurrentElementAttribut("from", null));
note.setPriority(vu.getCurrentElementAttribut("priority", null));
note.setAnnotates(vu.getCurrentElementAttribut("annotates", null));
note.setApplyCurrent(vu.getCurrentElementAttribut("hs:apply-current", "Yes"));
notes.add(0, note);
}
if (notes.isEmpty()) {
notes = null;
}
return notes;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:XLFHandler.java
示例7: approveAllTransUnits
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 批准或取消批准所有的翻译单元
* @param approve
* true:批准;false:取消批准;
*/
public List<String> approveAllTransUnits(final boolean approve, final boolean checkTargetWidth) {
final ArrayList<String> list = new ArrayList<String>();
handleAllSegment(new PerFileHandler() {
public void handle(String fileName, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws ModifyException,
XPathParseException, XPathEvalException, NavException, UnsupportedEncodingException {
ap.selectXPath(XPATH_ALL_TU);
while (ap.evalXPath() != -1) {
String approvedValue = approve ? "yes" : "no";
changeApproveProp(vu.getVTDNav(), approvedValue, xm);
}
saveAndReparse(xm, fileName); // 保存并更新VTDNav对象
}
});
return list;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:XLFHandler.java
示例8: getChildrenContent
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 获取当前节点下所有指定元素名称的文本内容,含内部标记等子节点内容。
* @param elementName
* 子节点名称
* @throws XPathParseException
* @throws NavException
* @throws XPathEvalException
*/
public Vector<String> getChildrenContent(String elementName) throws XPathParseException, XPathEvalException,
NavException {
Vector<String> texts = new Vector<String>();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./" + elementName);
while (ap.evalXPath() != -1) {
vn.push();
texts.add(getElementContent());
vn.pop();
}
if (texts.isEmpty()) {
texts = null;
}
return texts;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:25,代码来源:VTDUtils.java
示例9: main
import com.ximpleware.XPathParseException; //导入依赖的package包/类
public static void main(String[] args) throws XPathParseException, XPathEvalException, NavException {
TSFileHandler ts = new TSFileHandler();
VTDGen vg = new VTDGen();
if (vg
.parseFile(
"/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf",
true)) {
ts.openFile("/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf");
System.out.println(ts.getSourceLanguage(3));
System.out.println(ts.getTargetLanguage(3));
// System.out
// .println(ts
// .analysisTranslatorProgress(
// vg.getNav(),
// "/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf",
// 0));
}
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:20,代码来源:TSFileHandler.java
示例10: getElementPureText
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 得到当前节点的纯文本。实体会被转义。若无文本内容返回 null。
* @exception XPathParseException
* ,XPathEvalException,NavException
*/
public String getElementPureText() throws XPathParseException, XPathEvalException, NavException {
String txtNode = "./text()";
AutoPilot ap = new AutoPilot(vn);
StringBuilder result = new StringBuilder();
ap.selectXPath(txtNode);
int txtIndex = -1;
boolean isNull = true;
while ((txtIndex = ap.evalXPath()) != -1) {
result.append(vn.toString(txtIndex));
if (isNull) {
isNull = false;
}
}
return isNull ? null : result.toString();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:VTDUtils.java
示例11: getFileCountInXliff
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 得到 File 节点个数(此方法仅用于解析单个文件时)
* @return ;
*/
public int getFileCountInXliff(String fileName) {
VTDNav vn = vnMap.get(fileName);
Assert.isNotNull(vn, Messages.getString("file.XLFHandler.msg4") + fileName);
AutoPilot ap = new AutoPilot(vn);
try {
ap.selectXPath("count(/xliff/file)");
int countAllFile = (int) ap.evalXPathToNumber(); // 整个 xliff 文件中的
// file 节点的个数
return countAllFile;
} catch (XPathParseException e) {
LOGGER.error("", e);
e.printStackTrace();
}
return -1;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:XLFHandler.java
示例12: getChildElementPureText
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 得到当前子节点的纯文本。实体会被转义。若无文本内容返回 null。
* @exception XPathParseException
* ,XPathEvalException,NavException
*/
public String getChildElementPureText(VTDNav vn) throws XPathParseException, XPathEvalException, NavException {
String txtNode = ".//text()";
AutoPilot ap = new AutoPilot(vn);
StringBuilder result = new StringBuilder();
ap.selectXPath(txtNode);
int txtIndex = -1;
boolean isNull = true;
while ((txtIndex = ap.evalXPath()) != -1) {
result.append(vn.toString(txtIndex));
if (isNull) {
isNull = false;
}
}
return isNull ? null : result.toString();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:Martif2Tbx.java
示例13: getNotes
import com.ximpleware.XPathParseException; //导入依赖的package包/类
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
Vector<NoteBean> notes = new Vector<NoteBean>();
VTDNav vn = vu.getVTDNav();
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./note");
while (ap.evalXPath() != -1) {
NoteBean note = new NoteBean(vu.getElementContent());
note.setLang(vu.getCurrentElementAttribut("xml:lang", null));
note.setFrom(vu.getCurrentElementAttribut("from", null));
note.setPriority(vu.getCurrentElementAttribut("priority", null));
note.setAnnotates(vu.getCurrentElementAttribut("annotates", null));
note.setApplyCurrent(vu.getCurrentElementAttribut("hs:apply-current", "Yes"));
notes.add(0, note);
}
if (notes.isEmpty()) {
notes = null;
}
return notes;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:23,代码来源:XLFHandler.java
示例14: getElementRawPureText
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 得到当前节点的纯文本。实体不会被转义。若无文本内容返回 null。
* @exception XPathParseException
* ,XPathEvalException,NavException
*/
public String getElementRawPureText() throws XPathParseException, XPathEvalException, NavException {
String txtNode = "./text()";
AutoPilot ap = new AutoPilot(vn);
StringBuilder result = new StringBuilder();
ap.selectXPath(txtNode);
int txtIndex = -1;
while ((txtIndex = ap.evalXPath()) != -1) {
result.append(vn.toRawString(txtIndex));
}
if (result.length() == 0) {
return null;
} else {
return result.toString();
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:22,代码来源:VTDUtils.java
示例15: getElementAttribute
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 获得元素的属性值
* @param elementXPath
* 指定元素的 XPath
* @param attributeName
* 指定属性的名称
* @return
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* ;
*/
public String getElementAttribute(String elementXPath, String attributeName) throws XPathParseException,
XPathEvalException, NavException {
String text = null;
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath(elementXPath);
vn.push();
if (ap.evalXPath() != -1) {
int inx = vn.getAttrVal(attributeName);
if (inx != -1) {
text = vn.toString(inx);
}
}
vn.pop();
return text;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:28,代码来源:VTDUtils.java
示例16: testGetCurrentElementAttributsNoParams
import com.ximpleware.XPathParseException; //导入依赖的package包/类
@Test
public void testGetCurrentElementAttributsNoParams() throws XPathEvalException, NavException, XPathParseException{
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("//trans-unit[position()=2]");
ap.evalXPath();
Hashtable<String,String> eAtts = new Hashtable<String,String>();
eAtts.put("approved","yes");
eAtts.put("id","1");
eAtts.put("merged-trans","yes");
eAtts.put("reformat","yes");
eAtts.put("size-unit","pixel");
eAtts.put("translate","yes");
eAtts.put("xml:space","preserve");
eAtts.put("hs:ext","yes");
eAtts.put("xsi:test", "test");
Hashtable<String,String> aAtts = vu.getCurrentElementAttributs();
assertEquals(eAtts,aAtts);
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:VTDUtilsTest.java
示例17: testGetCurrentElementAttributs1Param
import com.ximpleware.XPathParseException; //导入依赖的package包/类
@Test
public void testGetCurrentElementAttributs1Param() throws XPathParseException, XPathEvalException, NavException{
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("//trans-unit[position()=2]");
ap.evalXPath();
Hashtable<String,String> eAtts = new Hashtable<String,String>();
eAtts.put("approved","yes");
eAtts.put("id","1");
eAtts.put("merged-trans","yes");
eAtts.put("reformat","yes");
eAtts.put("size-unit","pixel");
eAtts.put("translate","yes");
eAtts.put("xml:space","preserve");
eAtts.put("hs:ext","yes");
eAtts.put("xsi:test", "test");
Hashtable<String,String> aAtts = vu.getCurrentElementAttributs("es","http://www.heartsome.net.cn/2008/XLFExtension");
assertEquals(eAtts,aAtts);
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:VTDUtilsTest.java
示例18: getFieldMap
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* 获取配置文件中的项目文本字段信息
* @return
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException ;
*/
private LinkedHashMap<String, String> getFieldMap() throws XPathParseException, XPathEvalException, NavException {
AutoPilot ap = new AutoPilot(vu.getVTDNav());
Map<String, String> mapField = new HashMap<String, String>();
ap.selectXPath("/projectDescription/hs//fieldList/field");
while (ap.evalXPath() != -1) {
String fieldName = TextUtil.stringToXML(vu.getCurrentElementAttribut("name", ""));
String fieldValue = vu.getElementContent();
mapField.put(fieldName, fieldValue);
}
List<Entry<String, String>> lstAttr = new ArrayList<Entry<String, String>>(mapField.entrySet());
final Collator collatorChinese = Collator.getInstance(java.util.Locale.CHINA);
Collections.sort(lstAttr, new Comparator<Entry<String, String>>() {
public int compare(Entry<String, String> arg0, Entry<String, String> arg1) {
return collatorChinese.compare(arg0.getKey(), arg1.getKey());
}
});
LinkedHashMap<String, String> linkedMapAttr = new LinkedHashMap<String, String>();
for (Entry<String, String> entry : lstAttr) {
linkedMapAttr.put(entry.getKey(), entry.getValue());
}
return linkedMapAttr;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:31,代码来源:ProjectConfiger.java
示例19: getElementAttributs
import com.ximpleware.XPathParseException; //导入依赖的package包/类
/**
* <div style='color:red;'>这个方法是从 VTDUtils 类中考贝的,主要是要有一定的顺序</div>
* @param vn
* @return
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
*/
private Map<String, String> getElementAttributs(VTDNav vn)
throws XPathParseException, XPathEvalException, NavException {
vn.push();
Map<String, String> attributes = new LinkedHashMap<String, String>();
AutoPilot apAttributes = new AutoPilot(vn);
apAttributes.selectXPath("@*");
int inx = -1;
while ((inx = apAttributes.evalXPath()) != -1) {
String name = vn.toString(inx);
inx = vn.getAttrVal(name);
String value = inx != -1 ? vn.toString(inx) : "";
attributes.put(name, value);
}
apAttributes.resetXPath();
if (attributes.isEmpty()) {
attributes = null;
}
vn.pop();
return attributes;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:31,代码来源:Wf2Xliff.java
示例20: getElementAttribute
import com.ximpleware.XPathParseException; //导入依赖的package包/类
public String getElementAttribute(String elementXPath, String attributeName, VTDNav vn) throws XPathParseException,
XPathEvalException, NavException {
String text = null;
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace(PREFIX_A, NAMESPACE_A);
ap.declareXPathNameSpace(PREFIX_P, NAMESPACE_P);
ap.selectXPath(elementXPath);
vn.push();
if (ap.evalXPath() != -1) {
int inx = vn.getAttrVal(attributeName);
if (inx != -1) {
text = vn.toString(inx);
}
}
vn.pop();
return text;
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:PPTX2XLIFF.java
注:本文中的com.ximpleware.XPathParseException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论