use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class VTDUtils method getElementContent.
/**
* 得到指定节点的完整内容,包含子节点及文本。若无文本内容返回 null。
* @param xpath
* 指定节点的XPath。
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* @exception XPathParseException
* ,XPathEvalException,NavException
*/
public String getElementContent(String xpath) throws NavException, XPathParseException, XPathEvalException {
String text = null;
if (xpath != null && !xpath.equals("")) {
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath(xpath);
vn.push();
if (ap.evalXPath() != -1) {
text = getElementContent();
}
vn.pop();
}
return text;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class VTDUtils method getChildContent.
/**
* 获取当前节点下所有指定元素名称的文本内容,含内部标记等子节点内容。
* @param elementName
* 子节点名称
* @return String 指定子节点内容,无内容返回 null。
* @throws XPathParseException
* @throws NavException
* @throws XPathEvalException
*/
public String getChildContent(String elementName) throws XPathParseException, XPathEvalException, NavException {
String text = null;
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./" + elementName);
vn.push();
if (ap.evalXPath() != -1) {
text = getElementContent();
}
vn.pop();
return text;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class VTDUtils method getChildElementsCount.
/**
* 返回当前节点下一级子节点的个数。
* @return
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* ;
*/
public int getChildElementsCount() throws XPathParseException, XPathEvalException, NavException {
int result = 0;
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./*");
vn.push();
while (ap.evalXPath() != -1) {
result++;
}
vn.pop();
return result;
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class XliffReader method ananysisTag.
private void ananysisTag(Map<Integer, String[]> targetMap) throws VTDException {
VTDNav vn = vu.getVTDNav();
vn.push();
int idex = vn.getCurrentIndex();
String tagName = vn.toString(idex);
if ("g".equals(tagName)) {
String ctype = vu.getCurrentElementAttribut("ctype", null);
String rpr = vu.getCurrentElementAttribut("rPr", "");
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./node() | text()");
while (ap.evalXPath() != -1) {
idex = vn.getCurrentIndex();
int tokenType = vn.getTokenType(idex);
if (tokenType == 0) {
String name = vu.getCurrentElementName();
if ("ph".equals(name)) {
targetMap.put(idex, new String[] { vu.getElementContent(), rpr, ctype });
} else if ("g".equals(name)) {
ananysisTag(targetMap);
}
} else if (tokenType == 5) {
targetMap.put(idex, new String[] { vn.toRawString(idex), rpr, ctype });
}
}
} else if ("ph".equals(tagName)) {
targetMap.put(idex, new String[] { vu.getElementContent(), null, null });
} else {
// 其他节点,一律当做字符串处理
targetMap.put(idex, new String[] { vu.getElementFragment(), null, null });
}
vn.pop();
}
use of com.ximpleware.AutoPilot in project translationstudio8 by heartsome.
the class ArrangeTTX method getRawTextToken.
/**
* 取出 Raw 节点下的文本子节点的 token 值进行存放,单独进行处理
*/
private void getRawTextToken() throws Exception {
AutoPilot ap = new AutoPilot(sklVN);
String xpath = "/TRADOStag/Body/Raw/text()";
ap.selectXPath(xpath);
while (ap.evalXPath() != -1) {
rawTextTokenList.add(sklVN.getCurrentIndex());
}
}
Aggregations