本文整理汇总了Java中com.ximpleware.VTDGen.parseFile方法的典型用法代码示例。如果您正苦于以下问题:Java VTDGen.parseFile方法的具体用法?Java VTDGen.parseFile怎么用?Java VTDGen.parseFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ximpleware.VTDGen
的用法示例。
在下文中一共展示了VTDGen.parseFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertVersionIntoOriginalIfNecessary
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
private void insertVersionIntoOriginalIfNecessary(final String pOwnVersionOrNull)
throws ModifyException, NavException, UnsupportedEncodingException, IOException, TranscodeException {
if (pOwnVersionOrNull != null) {
final VTDGen gen = new VTDGen();
gen.enableIgnoredWhiteSpace(true);
final XMLModifier modifier = new XMLModifier();
if (gen.parseFile(file.getAbsolutePath(), false)) {
final VTDNav vn = gen.getNav();
modifier.bind(vn);
if (vn.toElement(FC, ARTIFACT_ID)) {
final long l = vn.expandWhiteSpaces(vn.getElementFragment(), WS_LEADING);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
vn.dumpFragment(l, out);
final String version = new String(out.toByteArray()).replaceAll(ARTIFACT_ID_PATTERN,
format(VERSION_FORMAT, pOwnVersionOrNull));
modifier.insertAfterElement(version);
}
}
try (final FileOutputStream out = new FileOutputStream(file)) {
modifier.output(out);
}
}
}
示例2: main
import com.ximpleware.VTDGen; //导入方法依赖的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));
}
}
示例3: copyMqSklToHsSkl
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 将mq 的骨架文件拷到R8 的骨架文件中
* @throws Exception
*/
private void copyMqSklToHsSkl(File mqSkeletonFile) throws Exception {
VTDGen vg = new VTDGen();
AutoPilot ap = new AutoPilot();
String mqSklContent = "";
String xpath = "/mq:externalparts";
if(vg.parseFile(mqSkeletonFile.getAbsolutePath(), true)){
VTDNav vn = vg.getNav();
ap.bind(vn);
VTDUtils vu = new VTDUtils(vn);
ap.declareXPathNameSpace("mq", "MemoQ Xliff external parts");
ap.selectXPath(xpath);
if (ap.evalXPath() != -1) {
mqSklContent = vu.getElementContent();
}
}
//下面添加到 r8 的骨架文件中去
ap.bind(sklVN);
xpath = "/xliff/file/header/skl";
ap.selectXPath(xpath);
if (ap.evalXPath() != -1) {
sklXM.insertAfterElement("<sklContent>" + mqSklContent + "</sklContent>");
sklXM.output(skeletonFile);
}
}
示例4: main
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
public static void main(String[] s) throws Exception {
// instantiate VTDGen and XMLModifier
VTDGen vg = new VTDGen();
XMLModifier xm = new XMLModifier();
AutoPilot ap = new AutoPilot();
AutoPilot ap2 = new AutoPilot();
ap.selectXPath("(/*/*/*)[position()>1 and position()<4]");
ap2.selectXPath("/*/*/*");
if (vg.parseFile("soap2.xml", true)) {
VTDNav vn = vg.getNav();
xm.bind(vn);
ap2.bind(vn);
ap.bind(vn);
ap2.evalXPath();
ElementFragmentNs ef = vn.getElementFragmentNs();
int i = -1;
while ((i = ap.evalXPath()) != -1) {
xm.insertAfterElement(ef);
}
xm.output(new FileOutputStream("new_soap.xml"));
}
}
示例5: parseOutputFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析结果文件(解析时这个结果文件还是一个骨架文件)
* @param file
* @throws Exception
*/
private void parseOutputFile(String file, String xliffFile) throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(file, true)) {
outputVN = vg.getNav();
outputXM = new XMLModifier(outputVN);
outputAP = new AutoPilot(outputVN);
outputVU = new VTDUtils(outputVN);
}else {
String errorInfo = MessageFormat.format("文件 {0} 的骨架信息无法解析,逆转换失败!",
new Object[]{new File(xliffFile).getName()});
throw new Exception(errorInfo);
}
}
示例6: parseXML
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析TMX文件 ;
*/
private boolean parseXML(String xmlLocation){
VTDGen vg = new VTDGen();
boolean result = vg.parseFile(xmlLocation, true);
if (result) {
VTDNav vtdNav = vg.getNav();
vnMap.put(xmlLocation, vtdNav);
}
return result;
}
示例7: saveAndReparse
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
protected boolean saveAndReparse(XMLModifier xm, String fileName) {
boolean isSaved = save(xm, fileName);
if (!isSaved) {
logger.debug(Messages.getString("qa.QAXmlHandler.logger3"));
return false;
}
// 重新加载
VTDGen vg = new VTDGen();
if (vg.parseFile(fileName, true)) {
vnMap.put(fileName, vg.getNav());
return true;
}
return false;
}
示例8: parseXlfFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析要被逆转换的xliff文件
* @param xliffFile
* @throws Exception
*/
private void parseXlfFile(String xliffFile) throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(xliffFile, true)) {
xlfVN = vg.getNav();
}else {
String errorInfo = MessageFormat.format(Messages.getString("mq.parse.msg1"),
new Object[]{new File(xliffFile).getName()});
throw new Exception(errorInfo);
}
}
示例9: parseOutputFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析结果文件(解析时这个结果文件还是一个骨架文件)
* @param file
* @throws Exception
*/
private void parseOutputFile(String file, String xliffFile) throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(file, true)) {
outputVN = vg.getNav();
outputXM = new XMLModifier(outputVN);
outputAP = new AutoPilot(outputVN);
outputAP.declareXPathNameSpace("sdl", "http://sdl.com/FileTypes/SdlXliff/1.0");
}else {
String errorInfo = MessageFormat.format(Messages.getString("sdl.parse.msg2"),
new Object[]{new File(xliffFile).getName()});
throw new Exception(errorInfo);
}
}
示例10: XliffUpdater
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
XliffUpdater() throws ExportExternalException {
VTDGen vg = new VTDGen();
if (!vg.parseFile(xliffFile, true)) {
throw new ExportExternalException(MessageFormat.format(
Messages.getString("ExportDocxDialog.ok.parseError"), _xliff));
}
try {
vn = vg.getNav();
xm = new XMLModifier(vn);
ap = new AutoPilot(vn);
tmpAp = new AutoPilot(vn);
ap.selectXPath("/xliff/file/@target-language");
tgtLang = ap.evalXPathToString();
if (tgtLang.isEmpty()) {
ap.selectXPath("/xliff/file/body//trans-unit/target/@xml:lang/text()");
vn.pop();
while (ap.evalXPath() != -1) {
tgtLang = vn.toString(vn.getCurrentIndex());
break;
}
vn.push();
}
ap.selectXPath("/xliff/file[1]/body/descendant::trans-unit[1]");
if (ap.evalXPath() == -1) {
throw new ExportExternalException(Messages.getString("ImportDocxDialog.import.errorTip3"));
}
} catch (Exception e) {
throw new ExportExternalException(MessageFormat.format(
Messages.getString("ExportDocxDialog.ok.parseError"), _xliff), e);
}
}
示例11: parseXlfFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析要被逆转换的xliff文件
* @param xliffFile
* @throws Exception
*/
private void parseXlfFile(String xliffFile) throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(xliffFile, true)) {
hsxlfVN = vg.getNav();
}else {
String errorInfo = MessageFormat.format(Messages.getString("du.parse.msg1"),
new Object[]{new File(xliffFile).getName()});
throw new Exception(errorInfo);
}
}
示例12: parseSkeletonFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析骨架文件,此时的骨架文件的内容就是源文件的内容
* @throws Exception
*/
private void parseSkeletonFile() throws Exception{
String errorInfo = "";
VTDGen vg = new VTDGen();
if (vg.parseFile(skeletonFile, true)) {
sklVN = vg.getNav();
sklXM = new XMLModifier(sklVN);
}else {
errorInfo = MessageFormat.format(Messages.getString("wf.parse.msg1"),
new Object[]{new File(inputFile).getName()});
throw new Exception(errorInfo);
}
}
示例13: openFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析文件(同时操作进度条)
* @param file
* @param monitor
* @param totalWork
* @return ;
*/
private int openFile(String tmxLocation, IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
try {
// 解析文件并获取索引
VTDGen vg = new VTDGen();
if (vg.parseFile(tmxLocation, true)) {
vn = vg.getNav();
if (monitor.isCanceled()) {
return 0; // 终止程序的执行
}
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("/tmx");
if (ap.evalXPath() == -1) {
return -2; // 解析的文件不符合TMX标准
}
monitor.worked(1);
return 1; // TMX文件解析成功
} else {
return -1; // 解析失败
}
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("", e);
}
return -1;
}
示例14: parseOutputFile
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
* 解析结果文件(解析时这个结果文件还是一个骨架文件)
* @param file
* @throws Exception
*/
private void parseOutputFile(String file, String xliffFile) throws Exception {
// copyFile(file, "C:\\Users\\Administrator\\Desktop\\test.xml");
VTDGen vg = new VTDGen();
if (vg.parseFile(file, true)) {
sklVN = vg.getNav();
sklXM = new XMLModifier(sklVN);
sklAP = new AutoPilot(sklVN);
sklAP.declareXPathNameSpace("mq", "MQXliff");
}else {
String errorInfo = MessageFormat.format(Messages.getString("mq.parse.msg2"),
new Object[]{new File(xliffFile).getName()});
throw new Exception(errorInfo);
}
}
示例15: setUp
import com.ximpleware.VTDGen; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(testFile, true)) {
vn = vg.getNav();
vu = new VTDUtils(vn);
}
}