本文整理汇总了Java中com.ximpleware.VTDGen类的典型用法代码示例。如果您正苦于以下问题:Java VTDGen类的具体用法?Java VTDGen怎么用?Java VTDGen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VTDGen类属于com.ximpleware包,在下文中一共展示了VTDGen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
}
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:27,代码来源:VersionTransferWriter.java
示例2: getFileId
import com.ximpleware.VTDGen; //导入依赖的package包/类
private String getFileId(BufferedReader reader) throws IOException, VTDException {
reader.mark(1024);
String str = reader.readLine();
str += "</FILE>";
reader.reset();
byte[] b = str.getBytes("UTF-8");
VTDGen vg = new VTDGen();
vg.setDoc(b);
vg.parse(false);
VTDNav vn = vg.getNav();
require(vn.toElement(VTDNav.ROOT));
String fileId = vn.toString(vn.getAttrVal(AgigaConstants.FILE_ID));
return fileId;
}
开发者ID:mgormley,项目名称:agiga,代码行数:17,代码来源:StreamingVtdXmlReader.java
示例3: editPlugindata
import com.ximpleware.VTDGen; //导入依赖的package包/类
private void editPlugindata(PluginConfigBean bean) {
VTDGen vg = new VTDGen();
vg.parseFile(pluginXmlLocation, true);
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
try {
ap.selectXPath(manage.buildXpath(curPluginBean));
XMLModifier xm = new XMLModifier(vn);
while (ap.evalXPath() != -1) {
xm.remove();
xm.insertAfterElement(manage.buildPluginData(bean));
manage.updataPluginMenu(bean);
}
FileOutputStream fos = new FileOutputStream(pluginXmlLocation);
BufferedOutputStream bos = new BufferedOutputStream(fos);
xm.output(bos); // 写入文件
bos.close();
fos.close();
} catch (Exception e) {
LOGGER.error("", e);
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:PluginConfigManageDialog.java
示例4: 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);
}
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:30,代码来源:Mq2Xliff.java
示例5: getNonTextContent
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* Get rPh & phoneticPr Element fragment
* @return ;
*/
private String getNonTextContent(){
StringBuffer result = new StringBuffer();
VTDGen vg = new VTDGen();
vg.setDoc(content.getBytes());
VTDUtils vu = null;
try {
vg.parse(true);
vu = new VTDUtils(vg.getNav());
AutoPilot ap = new AutoPilot(vu.getVTDNav());
ap.selectXPath("/si/rPh | phoneticPr");
while(ap.evalXPath() != -1){
result.append(vu.getElementFragment());
}
} catch (VTDException e) {
e.printStackTrace();
}
return result.toString();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:24,代码来源:Cell.java
示例6: loadFile
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 解析文件
* @param nameSpaceMap 要申明的命名空间
* @throws Exception
*/
protected void loadFile(Map<String, String> nameSpaceMap) throws Exception {
VTDGen vg = new VTDGen();
if (vg.parseFile(partPath, true)) {
vn = vg.getNav();
ap = new AutoPilot(vn);
otherAP = new AutoPilot(vn);
childAP = new AutoPilot(vn);
extendAP = new AutoPilot(vn);
vu = new VTDUtils(vn);
xm = new XMLModifier(vn);
// 给 ap 申明命名空间
for(Entry<String, String> entry : nameSpaceMap.entrySet()){
ap.declareXPathNameSpace(entry.getKey(), entry.getValue());
childAP.declareXPathNameSpace(entry.getKey(), entry.getValue());
otherAP.declareXPathNameSpace(entry.getKey(), entry.getValue());
extendAP.declareXPathNameSpace(entry.getKey(), entry.getValue());
}
}else {
throw new DocxConverterException(MessageFormat.format(Messages.getString("docxConvert.msg2"), partPath));
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:27,代码来源:PartOperate.java
示例7: loadSegment
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 解析 XLIFF 文件,获取所有文本段集合
* @throws NavException
* @throws XPathParseException
* @throws XPathEvalException
*/
private void loadSegment() throws NavException, XPathParseException, XPathEvalException {
VTDGen vg = new VTDGen();
if (vg.parseFile(strXLIFFPath, true)) {
VTDNav vn = vg.getNav();
VTDUtils vu = new VTDUtils(vn);
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("/xliff/file/body//trans-unit");
while (ap.evalXPath() != -1) {
String strTuId = vu.getCurrentElementAttribut("id", null);
String strSource = vu.getElementContent("./source");
String strTarget = vu.getElementContent("./target");
mapSegment.put(strTuId, new String[] { strSource, strTarget });
}
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:22,代码来源:XLIFF2PPTX.java
示例8: getTagId
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 根据一个<g>标记的头部获取标记的 id 属性值
* @param tagStr
* @return
*/
private String getTagId(String tagStr) throws Exception {
String tagId = "";
VTDGen vg = new VTDGen();
vg.setDoc(tagStr.getBytes());
vg.parse(false);
VTDNav vn = vg.getNav();
tagAP = new AutoPilot(vn);
tagAP.selectXPath("/g");
int index = -1;
if (tagAP.evalXPath() != -1) {
if ((index = vn.getAttrVal("id")) != -1) {
tagId = vn.toRawString(index);
}
}
return tagId;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:22,代码来源:Xliff2Ttx.java
示例9: XliffUtil
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 直接通过 RowID 来定位,适用于最常见的在界面 NatTable 中显示的文本段。
* @param rowID
*/
public XliffUtil(String rowID) {
this.rowID = rowID;
this.xlfFile = RowIdUtil.getFileNameByRowId(rowID);
this.fileXPath = RowIdUtil.getFileXpathByRowId(rowID);
this.tuid = RowIdUtil.getTUIdByRowId(rowID);
this.vg = new VTDGen();
if (vg.parseFile(xlfFile, true)) {
VTDNav vn = vg.getNav();
try {
vu = new VTDUtils(vn);
} catch (NavException e) {
e.printStackTrace();
}
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:20,代码来源:XliffUtil.java
示例10: XliffUtil
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 通过可组成 RowID 的三个参数来定位,适用于不在界面 NatTable 中显示的文本段, 如合并后变为空的 trans-unit 节点。
* @param xlfFile
* XLIFF 文件路径
* @param originalFile
* 源文件路径,建议从相邻文本段中用本类方法获取
* @param tuid
* 翻译单元 ID
*/
public XliffUtil(String xlfFile, String originalFile, String tuid) {
this.xlfFile = xlfFile;
this.fileXPath = "/xliff/file[@original=\"" + originalFile + "\"]";
this.tuid = tuid;
this.rowID = RowIdUtil.getRowId(xlfFile, originalFile, tuid);
this.vg = new VTDGen();
if (vg.parseFile(xlfFile, true)) {
VTDNav vn = vg.getNav();
try {
vu = new VTDUtils(vn);
} catch (NavException e) {
e.printStackTrace();
}
}
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:25,代码来源:XliffUtil.java
示例11: updateProjectParentVersion
import com.ximpleware.VTDGen; //导入依赖的package包/类
void updateProjectParentVersion(MavenProject project, Version version) throws MojoExecutionException {
try {
VTDGen gen = new VTDGen();
gen.enableIgnoredWhiteSpace(true);
gen.parseFile(project.getFile().getAbsolutePath(), true);
VTDNav nav = gen.getNav();
AutoPilot ap = new AutoPilot(nav);
ap.selectXPath("namespace-uri(.)");
String ns = ap.evalXPathToString();
nav.toElementNS(VTDNav.FIRST_CHILD, ns, "parent");
nav.toElementNS(VTDNav.FIRST_CHILD, ns, "version");
int pos = nav.getText();
XMLModifier mod = new XMLModifier(nav);
mod.updateToken(pos, version.toString());
try (OutputStream out = new FileOutputStream(project.getFile())) {
mod.output(out);
}
} catch (IOException | ModifyException | NavException | XPathParseException | TranscodeException e) {
throw new MojoExecutionException("Failed to update the parent version of project " + project, e);
}
}
开发者ID:revapi,项目名称:revapi,代码行数:26,代码来源:AbstractVersionModifyingMojo.java
示例12: openFile
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 打开指定的主文件和对应的子文件
* @param mainFilePath
* 主文件完整路径
* @param subFiles
* 子文件完整路径
* @throws Exception
* ;
*/
public void openFile(String mainFilePath, List<String> subFiles, IProgressMonitor monitor) throws Exception {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
this.mainfilePath = mainFilePath;
File file = new File(mainFilePath);
mainFileEncoding = FileEncodingDetector.detectFileEncoding(file);
VTDGen vg = VTDLoader.loadVTDGen(file, mainFileEncoding);
VTDNav vn = vg.getNav();
initTmxVersion(vn);
this.subFiles = subFiles;
monitor.beginTask("", 10);
openSubFiles(new SubProgressMonitor(monitor, 6));
loadAllLang(new SubProgressMonitor(monitor, 2));
monitor.worked(2);
VTDUtils vu = vus.get(subFiles.get(0));
loadTmxHeader(vu.getVTDNav());
monitor.done();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:29,代码来源:TmxLargeFileContainer.java
示例13: openSubFiles
import com.ximpleware.VTDGen; //导入依赖的package包/类
private void openSubFiles(IProgressMonitor monitor) throws Exception {
if (subFiles == null || subFiles.size() == 0) {
throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
}
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask("", subFiles.size());
VTDGen vg = new VTDGen();
for (String file : subFiles) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
File f = new File(file);
if (!f.exists() || f.isDirectory()) {
throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
}
parseFile(vg, f, new SubProgressMonitor(monitor, 1));
VTDUtils vu = new VTDUtils(vg.getNav());
vus.put(file, vu);
tuTotalNumber += countFileTuNumber(vu);
vg.clear();
}
monitor.done();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:TmxLargeFileContainer.java
示例14: 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));
}
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:20,代码来源:TSFileHandler.java
示例15: getElementFragment
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 获得整个节点的段落
* @return 整个节点的段落,例如:<ph id="1">a</ph>
* @throws NavException
* ;
*/
public String getElementFragment() throws NavException {
long l = vn.getElementFragment();
int offset = (int) l;
int len = (int) (l >> 32);
/* 区别编码。在解析 UTF-16 等部分编码的时候索引会变为2倍。 */
if (vn.getEncoding() > VTDGen.FORMAT_WIN_1258) {
offset = offset >> 1;
len = len >> 1;
}
// 处理这种情况下获取内容错误的情况 <ph>...</ph> 1><ph>...</ph> robert 2012-09-13
String fragment = vn.toRawString(offset, len);
int length = fragment.length();
int realEndIdx = fragment.indexOf(">", fragment.lastIndexOf("<"));
if (realEndIdx != length - 1) {
fragment = fragment.substring(0, fragment.indexOf(">", fragment.lastIndexOf("<")) + 1);
}
return fragment;
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:VTDUtils.java
示例16: 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"));
}
}
开发者ID:dongritengfei,项目名称:VTD-XML,代码行数:23,代码来源:FragmentTest.java
示例17: saveAndReparse
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 保存修改并更新VTDNav对象
* @param xm
* XMLModifier对象
* @param fileName
* 文件名
* @return 是否成功;
*/
public void saveAndReparse(final XMLModifier xm, final String fileName) {
boolean isSaved = save(xm, fileName);
if (!isSaved) {
LOGGER.error(Messages.getString("file.XLFHandler.logger8"));
return;
}
XLFHandler.this.resetCache();
// 重新加载
VTDGen vg = new VTDGen();
if (vg.parseFile(fileName, true)) {
vnMap.put(fileName, vg.getNav());
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:XLFHandler.java
示例18: openFile
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 打开 XLP 文件
* @param xlpPath
* XLP 文件路径
* @return ;
*/
private VTDNav openFile(String xlpPath) {
VTDGen vg = new VTDGen();
if (vg.parseFile(xlpPath, true)) {
return vg.getNav();
} else {
String errorMsg = MessageFormat.format(Messages.getString("file.XLPHandler.logger1"), xlpPath);
LOGGER.error(errorMsg);
return null;
}
}
开发者ID:heartsome,项目名称:translationstudio8,代码行数:17,代码来源:XLPHandler.java
示例19: getSheets
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* Method to get all sheets from which data was requested.
*
* @param workBook excel document
* @param xssfReader package reader of POI
* @param sheetName name of excel sheet
* @return list of sheets as {@code LinkedHashMap<String, InputStream>}
* @throws IOException can't open file
* @throws EncodingException
* @throws EOFException
* @throws EntityException
* @throws ParseException
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* @throws InvalidFormatException not an OOXML file
*/
private LinkedHashMap<String, InputStream> getSheets(InputStream workBook,
XSSFReader xssfReader, String sheetName) throws IOException, EncodingException,
EOFException, EntityException, ParseException, XPathParseException, XPathEvalException,
NavException, InvalidFormatException {
LinkedHashMap<String, InputStream> sheets = new LinkedHashMap<String, InputStream>();
String relationshipNS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
VTDGen wbkVg = new VTDGen();
byte[] wbByteArr = IOUtils.toByteArray(workBook);
wbkVg.setDoc(wbByteArr);
wbkVg.parse(true);
VTDNav wbVn = wbkVg.getNav();
AutoPilot wbAp = new AutoPilot(wbVn);
wbAp.declareXPathNameSpace("r", relationshipNS);
if (sheetName.equals("*")) {
wbAp.selectXPath("/workbook/sheets/sheet");
} else {
wbAp.selectXPath("/workbook/sheets/sheet[@name=\"" + sheetName + "\"]");
}
while (wbAp.evalXPath() != -1) {
String relId = wbVn.toRawString(wbVn.getAttrValNS(relationshipNS, "id"));
String curSheetName = wbVn.toRawString(wbVn.getAttrVal("name"));
sheets.put(curSheetName, xssfReader.getSheet(relId));
}
if (sheets.isEmpty()) {
throw new WebApplicationException(404);
}
return sheets;
}
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:53,代码来源:DataExcelVtdResource.java
示例20: initSpreadAllStory
import com.ximpleware.VTDGen; //导入依赖的package包/类
/**
* 加载 designmap.xml 文件,初始化 lstSpread 和 lstAllStory
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* ;
*/
private void initSpreadAllStory(IProgressMonitor monitor) throws XPathParseException, XPathEvalException,
NavException {
monitor.beginTask("", 1);
monitor.subTask(MessageFormat.format(Messages.getString("idml.IDML2XLIFF.task5"), "designmap.xml"));
VTDGen vg = new VTDGen();
if (vg.parseZIPFile(strSrcPath, "designmap.xml", true)) {
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace(IDML_PREFIX, IDML_NAMESPACE);
ap.selectXPath("/Document/node()");
while (ap.evalXPath() != -1) {
int curIndex = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIndex);
String name = vn.toString(curIndex);
// 节点
if (tokenType == 0) {
if (name.equals("idPkg:Spread")) {
String strSpread = vn.toString(vn.getAttrVal("src"));
lstSpread.add(strSpread);
} else if (name.equals("idPkg:Story")) {
String strStory = vn.toString(vn.getAttrVal("src"));
lstAllStory.add(strStory);
} else if (name.equals("idPkg:MasterSpread")) {
String strMasterSpread = vn.toString(vn.getAttrVal("src"));
lstMasterSpread.add(strMasterSpread);
}
}
}
}
monitor.worked(1);
monitor.done();
}
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:40,代码来源:IDML2XLIFF.java
注:本文中的com.ximpleware.VTDGen类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论