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


Java VTDGen.parseZIPFile方法代码示例

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


在下文中一共展示了VTDGen.parseZIPFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

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

示例2: writeDocumentxml

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
private void writeDocumentxml(XliffBean bean) throws ExportExternalException {
	VTDGen vg = new VTDGen();
	if (!vg.parseZIPFile(templateDocxFile, "word/document.xml", true)) {
		canceled();
		throw new ExportExternalException(Messages.getString("ExportExternal.error.templateError"));
	}
	try {
		VTDNav vn = vg.getNav();
		AutoPilot ap = new AutoPilot(vn);
		ap.declareXPathNameSpace("w", ExportExternal.NAMESPACE_W);
		ap.selectXPath("/w:document");
		if (ap.evalXPath() == -1) {
			throw new ExportExternalException(Messages.getString("ExportExternal.error.templateError"));
		}

		long l = vn.getElementFragment();
		int dOffset = (int) l;
		int dLength = (int) (l >> 32);

		ap.selectXPath("/w:document/w:body/w:p");
		if (ap.evalXPath() == -1) {
			// we should write in body!!
			canceled();
			throw new ExportExternalException(Messages.getString("ExportExternal.error.templateError"));
		} else {
			l = vn.getElementFragment();
			int offset = (int) l;
			int length = (int) (l >> 32);
			String str = vn.toString(0, length + offset);
			docxmlWriter.write(str);
			doc_end_fragment = vn.toString(length + offset, dOffset + dLength - offset - length);
		}
		//we should export some info about this unclean
	} catch (Exception e) {
		LOGGER.error("", e);
		canceled();
		throw new ExportExternalException(e.getMessage(), e);
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:40,代码来源:ExportConfig.java

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

示例4: StyleXml

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
public StyleXml(String template) throws Exception {
	VTDGen vg = new VTDGen();
	vg.parseZIPFile(template, "word/styles.xml", true);
	vn = vg.getNav();
	ap = new AutoPilot(vn);
	ap.declareXPathNameSpace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
	try {
		xm = new XMLModifier(vn);
	} catch (ModifyException e) {
		Exception e1 = new Exception(Messages.getString("converter.tmx2docx.template.notfound"));
		throw e1;
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:14,代码来源:Tmx2Docx.java

示例5: testUncelan

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
private int testUncelan(String path) {
		VTDGen vg = new VTDGen();
		if (!vg.parseZIPFile(path, "word/styles.xml", true)) {
			alertParseError(path);
			return -2;
		}
		VTDNav vn = vg.getNav();
		AutoPilot ap = new AutoPilot(vn);
		ap.declareXPathNameSpace("w", ExportExternal.NAMESPACE_W);
		try {
			ap.selectXPath("/w:styles/w:style[@w:styleId=\"tw4winMark\"]");
		} catch (XPathParseException e) {
			LOGGER.error("", e);
			return -2;
		}
		return ap.evalXPathToBoolean() ? ExportExternal.EXPORT_SDLUNCLEAN : -1;
	} 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:18,代码来源:ImportExternalDialog.java

示例6: testHsproof

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
private int testHsproof(String path) {
		StringBuilder builder = new StringBuilder();
		// hs proof
		VTDGen vg = new VTDGen();
		if (!vg.parseZIPFile(path, "word/document.xml", true)) {
			alertParseError(path);
			return -2;
		}
		VTDNav vn = vg.getNav();
		AutoPilot ap = new AutoPilot(vn);
		AutoPilot _ap = new AutoPilot(vn);
		ap.declareXPathNameSpace("w", ExportExternal.NAMESPACE_W);
		_ap.declareXPathNameSpace("w", ExportExternal.NAMESPACE_W);
		try {
			ap.selectXPath("count(/w:document/w:body/w:tbl/w:tr[1]/w:tc)");
			if (!ap.evalXPathToBoolean()) {
				return -1;
			}
			ap.selectXPath("/w:document/w:body/descendant::w:r");
			boolean inBegin = false;
			while (ap.evalXPath() != -1) {
				if (inBegin) {
					vn.push();
					_ap.selectXPath("./w:instrText/text()");
					while (_ap.evalXPath() != -1) {
						builder.append(vn.toString(vn.getCurrentIndex()));
					}
					vn.pop();
					_ap.selectXPath("./w:fldChar[@w:fldCharType='end']");
					if (_ap.evalXPathToBoolean()) {
						if (builder.toString().trim().contains(DocxConstant.HSDOCX_FLAG)) {
							return ExportExternal.EXPORT_HSPROOF;
						} else {
							builder.setLength(0);
						}
					}
				} else {
					_ap.selectXPath("./w:fldChar[@w:fldCharType='begin']");
					inBegin = _ap.evalXPathToBoolean();
					if (inBegin) {
						vn.push();
						_ap.selectXPath("./w:instrText/text()");
						while (_ap.evalXPath() != -1) {
							builder.append(vn.toString(vn.getCurrentIndex()));
						}
						vn.pop();
					}
				}
			}
		} catch (Exception e) {
			LOGGER.error("", e);
			return -2;
		}
		return -1;
	} 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:56,代码来源:ImportExternalDialog.java


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