当前位置: 首页>>代码示例>>Java>>正文


Java VTDGen.getNav方法代码示例

本文整理汇总了Java中com.ximpleware.VTDGen.getNav方法的典型用法代码示例。如果您正苦于以下问题:Java VTDGen.getNav方法的具体用法?Java VTDGen.getNav怎么用?Java VTDGen.getNav使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ximpleware.VTDGen的用法示例。


在下文中一共展示了VTDGen.getNav方法的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);
		}
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:27,代码来源:VersionTransferWriter.java

示例2: 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

示例3: 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,项目名称:translationstudio8,代码行数:22,代码来源:Xliff2Ttx.java

示例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"));
	}
}
 
开发者ID:dongritengfei,项目名称:VTD-XML,代码行数:23,代码来源:FragmentTest.java

示例5: getVU

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * @param xlfFile
 *            XLIFF 文件路径
 * @return VTDUtils
 */
public static VTDUtils getVU(String xlfFile) {
	VTDGen vg = new VTDGen();
	if (vg.parseFile(xlfFile, true)) {
		VTDNav vn = vg.getNav();
		try {
			return new VTDUtils(vn);
		} catch (NavException e) {
			e.printStackTrace();
		}
	}
	return null;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:XliffUtil.java

示例6: 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);
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:17,代码来源:Wf2Xliff.java

示例7: 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("sdl.parse.msg1"), 
				new Object[]{new File(xliffFile).getName()});
		throw new Exception(errorInfo);
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:16,代码来源:Xliff2Sdl.java

示例8: main

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * @param args
 *            ;
 * @throws NavException
 */
public static void main(String[] args) {
	// TODO Auto-generated method stub
	VTDGen vg = new VTDGen();
	if (vg.parseFile(utf_8, true)) {
		VTDNav vn = vg.getNav();
		try {
			VTDUtils vu = new VTDUtils(vn);
		} catch (NavException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:18,代码来源:TestDiffFileEncoding.java

示例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("du.parse.msg2"), 
				new Object[]{new File(xliffFile).getName()});
		throw new Exception(errorInfo);
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:19,代码来源:Xliff2Du.java

示例10: addSDLStyle

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * sdl 双语样式。
 * @throws ExportExternalException
 *             模板错误或者程序内部错误
 */
private void addSDLStyle() throws ExportExternalException {
	VTDGen vg = new VTDGen();
	if (!vg.parseZIPFile(templateDocxFile, "word/styles.xml", true)) {
		throw new ExportExternalException(Messages.getString("ExportExternal.error.templateError"));
	}
	VTDNav vn = vg.getNav();
	AutoPilot ap = new AutoPilot(vn);
	ap.declareXPathNameSpace("w", ExportExternal.NAMESPACE_W);

	String styleCode = "<w:style w:type=\"character\" w:customStyle=\"1\" w:styleId=\"tw4winMark\"><w:name w:val=\"tw4winMark\"/>"
			+ "<w:rPr><w:rFonts w:ascii=\"Courier New\" w:hAnsi=\"Courier New\" w:cs=\"Courier New\"/><w:vanish/><w:color w:val=\"800080\"/>"
			+ "</w:rPr></w:style>\n";
	String styleCode_tag = "<w:style w:type=\"character\" w:styleId=\"Tag\" w:customStyle=\"true\">"
			+ "<w:name w:val=\"Tag\"/><w:basedOn w:val=\"DefaultParagraphFont\"/><w:uiPriority w:val=\"1\"/><w:qFormat/><w:rPr><w:i/><w:color w:val=\"FF0066\"/></w:rPr></w:style>";
	String rowidStyle = "<w:style w:type=\"character\" w:styleId=\"HSRow\" w:customStyle=\"true\">" +
			"<w:name w:val=\"HSRow\" />" +
			"<w:rPr><w:rFonts w:ascii=\"Consolas\"/><w:color w:val=\"0070C0\"/><w:b /></w:rPr></w:style>";
	
	try {
		ap.selectXPath("/w:styles/w:style[last()]");
		if (ap.evalXPath() != -1) {
			XMLModifier xm = new XMLModifier(vn);
			xm.insertAfterElement(styleCode + styleCode_tag + rowidStyle);
			xm.output(tmpUnzipFolder + "/word/styles.xml");
		}
	} catch (Exception e) {
		LOGGER.error("", e);
		throw new ExportExternalException(e.getMessage(), e);
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:36,代码来源:ExportConfig.java

示例11: parseSlideMasterRels

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * 解析 ppt/slideMasters/_rels 目录下的 rels 文件,确定 slideMasterN.xml 与 slideLayoutN.xml 的对应关系
 * @throws XPathParseException
 * @throws XPathEvalException
 * @throws NavException
 *             ;
 */
private void parseSlideMasterRels(IProgressMonitor monitor) throws XPathParseException, XPathEvalException,
		NavException {
	File relsFile = new File(strTmpFolderPath + File.separator + "ppt" + File.separator + "slideMasters"
			+ File.separator + "_rels");
	if (relsFile.isDirectory()) {
		File[] arrRelFile = relsFile.listFiles();
		monitor.beginTask("", arrRelFile.length);
		VTDGen vg = new VTDGen();
		AutoPilot ap = new AutoPilot();
		VTDUtils vu = new VTDUtils();
		for (File relFile : arrRelFile) {
			String name = relFile.getName();
			monitor.subTask(MessageFormat.format(Messages.getString("pptx.PPTX2XLIFF.task4"), name));
			if (relFile.isFile() && name.toLowerCase().endsWith(".rels")) {
				if (vg.parseFile(relFile.getAbsolutePath(), true)) {
					ArrayList<String> lstLayout = new ArrayList<String>();
					VTDNav vn = vg.getNav();
					ap.bind(vn);
					vu.bind(vn);
					ap.selectXPath("/Relationships/Relationship");
					while (ap.evalXPath() != -1) {
						String strTarget = vu.getCurrentElementAttribut("Target", "");
						if (strTarget.indexOf("slideLayout") != -1) {
							strTarget = strTarget.substring(strTarget.lastIndexOf("/") + 1);
							lstLayout.add(strTarget);
						}
					}
					mapLayout.put(name.substring(0, name.lastIndexOf(".")), lstLayout);
				}
			}
			monitor.worked(1);
		}
	}
	monitor.done();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:43,代码来源:PPTX2XLIFF.java

示例12: 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);
			}
		}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:20,代码来源:Xliff2Mq.java

示例13: 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();
		xlfAP = new AutoPilot(xlfVN);
	}else {
		String errorInfo = MessageFormat.format("文件 {0} 的骨架信息无法解析,逆转换失败!", 
				new Object[]{new File(xliffFile).getName()});
		throw new Exception(errorInfo);
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:17,代码来源:Xliff2Ttx.java

示例14: parseFileWithVTD

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * Parse current TMX file with VTD
 * @return <code>VTDUtils<code>
 * @throws Exception
 *             A set of VTD parse exception;
 */
public void parseFileWithVTD() throws Exception {
	File f = new File(this.filePath);
	if (!f.exists() || f.isDirectory()) {
		throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
	}
	VTDGen vg = parseFile(f);
	vu = new VTDUtils(vg.getNav());
	loadTmxHeader(vu);
	getTUIndexCache(true);
	vg.clear();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:18,代码来源:TmxFileContainer.java

示例15: parseSlideLayout

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * 解析 slideLayoutN.xml 文件,获取坐标值,因为有的幻灯片中节点的坐标是存放在此文件中的
 * @throws NavException
 * @throws XPathParseException
 * @throws XPathEvalException
 */
private void parseSlideLayout() throws NavException, XPathParseException, XPathEvalException {
	File slideLayoutDic = new File(strTmpFolderPath + File.separator + "ppt" + File.separator + "slideLayouts");
	if (slideLayoutDic.isDirectory()) {
		VTDGen vg = new VTDGen();
		AutoPilot ap = new AutoPilot();
		ap.declareXPathNameSpace(PREFIX_A, NAMESPACE_A);
		ap.declareXPathNameSpace(PREFIX_P, NAMESPACE_P);
		VTDUtils vu = new VTDUtils();
		File[] arrSlideLayoutFile = slideLayoutDic.listFiles();
		for (File slideLayoutFile : arrSlideLayoutFile) {
			if (slideLayoutFile.isFile() && slideLayoutFile.getName().toLowerCase().endsWith(".xml")) {
				if (vg.parseFile(slideLayoutFile.getAbsolutePath(), true)) {
					String name = slideLayoutFile.getName();
					VTDNav vn = vg.getNav();
					ap.bind(vn);
					vu.bind(vn);
					ap.selectXPath("/p:sldLayout/p:cSld/p:spTree//p:sp[descendant::p:ph[not(@type='dt') and not(@type='sldNum')]]");
					ArrayList<String[]> lstPH = new ArrayList<String[]>();
					while (ap.evalXPath() != -1) {
						String strType = getElementAttribute(".//p:ph", "type", vn);
						String idx = getElementAttribute(".//p:ph", "idx", vn);
						if (strType == null && idx == null) {
							continue;
						}

						String strX = getElementAttribute(".//a:xfrm/a:off", "x", vn);
						String strY = getElementAttribute(".//a:xfrm/a:off", "y", vn);
						if (strX != null && strY != null) {
							lstPH.add(new String[] { strType, idx, strX, strY });
						}
					}
					if (lstPH.size() > 0) {
						mapSldLayoutPH.put(name, lstPH);
					}
				}
			}
		}
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:46,代码来源:PPTX2XLIFF.java


注:本文中的com.ximpleware.VTDGen.getNav方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。