Java Code Examples for com.ximpleware.VTDGen#clear()
The following examples show how to use
com.ximpleware.VTDGen#clear() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TmxReader.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Validate TMX Format,and pilot to Body XMLElement * @param vg * @throws TmxReadException * ; */ private void validateTmxAndParseHeader(VTDGen vg) throws TmxReadException { VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); String rootPath = "/tmx"; vu = new VTDUtils(); try { vu.bind(vn); ap.selectXPath(rootPath); if (ap.evalXPath() == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } ap.resetXPath(); ap.selectXPath("/tmx/header"); if (ap.evalXPath() == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } int id = vu.getVTDNav().getAttrVal("srclang"); if (id == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } header.setSrclang(vu.getVTDNav().toString(id).trim()); if (vu.pilot("/tmx/body") == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } // compute total tu number this.totalTu = vu.getChildElementsCount(); } catch (VTDException e) { logger.error("", e); throw new TmxReadException(Messages.getString("document.TmxReader.parseTmxFileError") + e.getMessage()); } finally { vg.clear(); } }
Example 2
Source File: TmxFileContainer.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * 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(); }
Example 3
Source File: TmxReader.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Validate TMX Format,and pilot to Body XMLElement * @param vg * @throws TmxReadException * ; */ private void validateTmxAndParseHeader(VTDGen vg) throws TmxReadException { VTDNav vn = vg.getNav(); AutoPilot ap = new AutoPilot(vn); String rootPath = "/tmx"; vu = new VTDUtils(); try { vu.bind(vn); ap.selectXPath(rootPath); if (ap.evalXPath() == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } ap.resetXPath(); ap.selectXPath("/tmx/header"); if (ap.evalXPath() == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } int id = vu.getVTDNav().getAttrVal("srclang"); if (id == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } header.setSrclang(vu.getVTDNav().toString(id).trim()); if (vu.pilot("/tmx/body") == -1) { throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError")); } // compute total tu number this.totalTu = vu.getChildElementsCount(); } catch (VTDException e) { logger.error("", e); throw new TmxReadException(Messages.getString("document.TmxReader.parseTmxFileError") + e.getMessage()); } finally { vg.clear(); } }