protected void setPath(String path) { if ( path == null ) { throw new IllegalArgumentException("path must be set"); } this.setWriteAllPropertiesAsAttributes(false); writer = new XMLWriter(path); mtAttribute = new Hashtable<String, String>(); mtAttribute.put(CREATIONID, Util.MTFLAG); altAttribute = new Hashtable<String, String>(); altAttribute.put(CREATIONID, FROMALTERNATE); }
/** * Saves the current rules to an SRX rules document. * * @param rulesPath * the full path of the file where to save the rules. * @param saveExtensions * true to save Okapi SRX extensions, false otherwise. * @param saveNonValidInfo * true to save non-SRX-valid attributes, false otherwise. */ public void saveRules(String rulesPath, boolean saveExtensions, boolean saveNonValidInfo) { XMLWriter writer = new XMLWriter(rulesPath); saveRules(writer, saveExtensions, saveNonValidInfo); }
/** * Saves the current rules to an SRX string. * * @param saveExtensions * true to save Okapi SRX extensions, false otherwise. * @param saveNonValidInfo * true to save non-SRX-valid attributes, false otherwise. * @return the string containing the saved SRX rules. */ public String saveRulesToString(boolean saveExtensions, boolean saveNonValidInfo) { StringWriter strWriter = new StringWriter(); XMLWriter writer = new XMLWriter(strWriter); boolean current = modified; saveRules(writer, saveExtensions, saveNonValidInfo); modified = current; // Keep the same state for modified writer.close(); return strWriter.toString(); }
@Override protected void startWriting(OutputStream outStream) { //this.outStream = outStream; prWriter = new PrintWriter(outStream); writer = new XMLWriter(prWriter); writer.writeStartDocument(); writer.writeStartElement("body"); writer.writeLineBreak(); }
private XMLWriter startTemporaryFiles () { // Create the HTML source file XMLWriter htmlWriter = new XMLWriter(htmlSourceFile.getPath()); // Start building the source file htmlWriter.writeStartElement("html"); htmlWriter.writeStartElement("meta"); htmlWriter.writeAttributeString("http-equiv", "Content-Type"); htmlWriter.writeAttributeString("content", "text/html; charset=UTF-8"); htmlWriter.writeEndElementLineBreak(); // Set the output name and make sure it's deleted String path = htmlSourceFile.getAbsolutePath(); path = Util.getDirectoryName(path) + File.separator + Util.getFilename(path, false) + ".trg.html"; htmlTargetFile = new File(path); if ( htmlTargetFile.exists() ) { htmlTargetFile.delete(); } // Create the store for the original source path = htmlSourceFile.getAbsolutePath(); path = Util.getDirectoryName(path) + File.separator + Util.getFilename(path, false) + ".ori.bin"; originalStoreFile = new File(path); store.create(originalStoreFile); return htmlWriter; }
private void startExtractedBlock () { try { File tmpFile = File.createTempFile("~okapi-45_gttbt_", ".html"); blocks.add(tmpFile); // Create the HTML file htmlWriter = new XMLWriter(tmpFile.getPath()); // Start building the source file htmlWriter.writeStartElement("html"); htmlWriter.writeStartElement("meta"); htmlWriter.writeAttributeString("http-equiv", "Content-Type"); htmlWriter.writeAttributeString("content", "text/html; charset=UTF-8"); htmlWriter.writeEndElementLineBreak(); count = 100; // Roughly } catch ( IOException e ) { throw new OkapiIOException("Error creating extraction file.", e); } }
private void processStartDocument (Event event) { StartDocument sd = (StartDocument)event.getResource(); // Create the output if ( outputStream == null ) { if (writer == null) { writer = new TMXWriter(outputPath); } else { writer.setPath(outputPath); } } else if ( outputStream != null ) { if (writer == null) { writer = new TMXWriter(new XMLWriter( new OutputStreamWriter(outputStream, StandardCharsets.UTF_8))); } else { writer.setXmlWriter(new XMLWriter( new OutputStreamWriter(outputStream, StandardCharsets.UTF_8))); } } writer.setWriteAllPropertiesAsAttributes(params.isWriteAllPropertiesAsAttributes()); writer.setExpandDuplicateProps(params.isEnableDuplicateProps()); writer.setPropValueSep(params.getPropValueSep()); writer.setGenerateUUID(params.isGenerateUUID()); writer.setNormalizeCodeIds(params.isNormalizeInlineIDs()); writer.writeStartDocument(sd, sd.getLocale(), locale, null, null, segType, "unknown", "text"); }
pathToOpen = getOutputFilename(); writer = new XMLWriter(getOutputFilename()); //$NON-NLS-1$ writer.writeStartDocument(); writer.writeStartElement("html"); //$NON-NLS-1$
public String toXML() { StringWriter sw = new StringWriter(); XMLWriter xml = new XMLWriter(sw); xml.writeStartDocument(); xml.writeStartElement("TranslateOptions"); xml.writeAttributeString("xmlns", "http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2"); xml.writeStartElement("Category"); xml.writeString(this.category); xml.writeEndElement(); xml.writeStartElement("ContentType"); xml.writeString(this.contentType); xml.writeEndElement(); xml.writeStartElement("ReservedFlags"); xml.writeEndElement(); xml.writeStartElement("State"); xml.writeEndElement(); xml.writeStartElement("Uri"); xml.writeEndElement(); xml.writeStartElement("User"); xml.writeString("defaultUser"); xml.writeEndElement(); xml.writeEndElement(); // !TranslateOptions xml.close(); return sw.toString(); } }
report = new XMLWriter(reportPath); report.writeStartDocument(); report.writeRawXML("<h1>Transifex Package Summary</h1>");
public String toXML() { StringWriter sw = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(sw); xmlWriter.writeStartDocument(); xmlWriter.writeStartElement("GetTranslationsArrayRequest");
XR = new XMLWriter(projectSaveFile); XR.writeStartDocument(); XR.writeStartElement("omegat");