private void writeAnnotatorsRefIfNeeded () { if ( needAnnotatorsRef && params.getIncludeIts() ) { writer.writeAttributeString(Namespaces.ITS_NS_PREFIX+":annotatorsRef", annotatorsRef.peek()); needAnnotatorsRef = false; } }
protected void writeAllPropertiesAsAttibutes (XMLWriter writer, Set<String> names, TextContainer item) { // Write any TUV-level properties as attributes (but only standard attributes) for ( String name : names ) { if (ATTR_NAMES.contains(";"+name+";") && !name.equals("tuid")) { writer.writeAttributeString(name, item.getProperty(name).getValue()); } } }
protected void writeAllPropertiesAsAttibutes (XMLWriter writer, Set<String> names, ITextUnit item) { // Write any TU-level properties as attributes (but only standard attributes) for ( String name : names ) { if ( ATTR_NAMES.contains(";"+name+";") && !name.equals("tuid")) { writer.writeAttributeString(name, item.getProperty(name).getValue()); } } }
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); } }
protected void writeProp(String name, String value) { // Write out the property if (expandDuplicateProps) { StringTokenizer st = new StringTokenizer(value, propValueSep, false); while (st.hasMoreTokens()) { writer.writeStartElement("prop"); writer.writeAttributeString("type", name); writer.writeString(st.nextToken()); writer.writeEndElementLineBreak(); // prop } } else { writer.writeStartElement("prop"); writer.writeAttributeString("type", name); writer.writeString(value); writer.writeEndElementLineBreak(); // prop } }
private static void writeSizeProperties(XMLWriter writer, INameable resource) { boolean sizeWritten = false; if (resource.hasProperty(Property.MAX_WIDTH)) { writer.writeAttributeString("maxwidth", resource.getProperty(Property.MAX_WIDTH).getValue()); sizeWritten = true; } if (resource.hasProperty(Property.MAX_HEIGHT)) { writer.writeAttributeString("maxheight", resource.getProperty(Property.MAX_HEIGHT).getValue()); sizeWritten = true; } if (sizeWritten) { if (resource.hasProperty(Property.SIZE_UNIT)) { writer.writeAttributeString("size-unit", resource.getProperty(Property.SIZE_UNIT).getValue()); } else { //default writer.writeAttributeString("size-unit", "pixel"); } } }
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; }
/** * Writes the start of a <group> element. * @see #writeEndGroup() */ public void writeStartGroup (StartGroup resource) { if ( !inFile ) { writeStartFile(original, dataType, skeletonPath, fwConfigId, fwInputEncoding, null); } String id = resource.getId(); String resName = resource.getName(); String resType = resource.getType(); writer.writeStartElement("group"); writer.writeAttributeString("id", id); if ( !Util.isEmpty(resName) ) { writer.writeAttributeString("resname", resName); } if ( !Util.isEmpty(resType) ) { if ( resType.startsWith("x-") || ( RESTYPEVALUES.contains(";"+resType+";")) ) { writer.writeAttributeString("restype", resType); } else { // Make sure the value is valid writer.writeAttributeString("restype", "x-"+resType); } } writeAnnotatorsRefIfNeeded(); writeSizeProperties(writer, resource); writer.writeLineBreak(); }
writer.writeAttributeString("version", "1.2"); writer.writeAttributeString("xmlns", Namespaces.NS_XLIFF12); writer.writeAttributeString("xmlns:okp", Namespaces.NS_XLIFFOKAPI); if ( params.getIncludeIts() ) { writer.writeAttributeString("xmlns:"+Namespaces.ITS_NS_PREFIX, Namespaces.ITS_NS_URI); writer.writeAttributeString("xmlns:"+Namespaces.ITSXLF_NS_PREFIX, Namespaces.ITSXLF_NS_URI); writer.writeAttributeString(Namespaces.ITS_NS_PREFIX+":version", "2.0");
writer.writeAttributeString("xmlns", NSURI_SRX20); if (saveExtensions) { writer.writeAttributeString("xmlns:" + NSPREFIX_OKPSRX, NSURI_OKPSRX); writer.writeAttributeString("version", "2.0"); version = "2.0"; writer.writeLineBreak(); writer.writeAttributeString("segmentsubflows", (segmentSubFlows ? "yes" : "no")); writer.writeAttributeString("cascade", (cascade ? "yes" : "no")); writer.writeLineBreak(); writer.writeAttributeString("type", "start"); writer.writeAttributeString("include", (includeStartCodes ? "yes" : "no")); writer.writeAttributeString("type", "end"); writer.writeAttributeString("include", (includeEndCodes ? "yes" : "no")); writer.writeAttributeString("type", "isolated"); writer.writeAttributeString("include", (includeIsolatedCodes ? "yes" : "no")); writer.writeAttributeString("oneSegmentIncludesAll", (oneSegmentIncludesAll ? "yes" : "no")); writer.writeAttributeString("trimLeadingWhitespaces", (trimLeadingWS ? "yes" : "no")); writer.writeAttributeString("trimTrailingWhitespaces", (trimTrailingWS ? "yes" : "no")); writer.writeAttributeString("useJavaRegex", "yes"); writer.writeAttributeString("useIcu4JBreakRules", (useIcu4JBreakRules ? "yes" : "no")); writer.writeAttributeString("treatIsolatedCodesAsWhitespace", (treatIsolatedCodesAsWhitespace ? "yes" : "no"));
private void writeXliffNotes(ITextUnit tu) { XLIFFNoteAnnotation notes = tu.getAnnotation(XLIFFNoteAnnotation.class); if (notes == null) { return; } for (XLIFFNote n : notes) { writer.writeStartElement("note"); // annotates if (n.getAnnotates() != null) { writer.writeAttributeString("annotates", n.getAnnotates().toString()); } // from if (n.getFrom() != null) { writer.writeAttributeString("from", n.getFrom()); } // priority if (n.getPriority() != null) { writer.writeAttributeString("priority", n.getPriority().toString()); } writer.writeString(n.getNoteText()); writer.writeEndElementLineBreak(); // note } }
String out = String.format("%d:%s:%s", subDocId, tu.getId(), seg.id); count += (out.length() + 10); htmlWriter.writeAttributeString("id", out); out = qutil.toCodedHTML(seg.text); try {
writer.writeStartElement("tu"); if ( !Util.isEmpty(tuid) ) { writer.writeAttributeString("tuid", tuid); writer.writeAttributeString("type", name); writer.writeString(attributes.get(name)); writer.writeAttributeString("xml:lang", srcLoc.toBCP47()); writer.writeStartElement("seg"); writer.writeRawXML(tmxCont.setContent(source).toString()); writer.writeAttributeString("xml:lang", ((altTrgLoc != null) ? altTrgLoc.toBCP47() : trgLoc.toBCP47())); writer.writeAttributeString(CREATIONID, attributes.get(CREATIONID));
writer.writeAttributeString("original", (original!=null) ? original : "unknown"); writer.writeAttributeString("source-language", srcLoc.toBCP47()); if ( trgLoc != null ) { writer.writeAttributeString("target-language", trgLoc.toBCP47()); writer.writeAttributeString("datatype", dataType); writer.writeAttributeString("okp:inputEncoding", inputEncoding); writer.writeAttributeString("okp:configId", configId); writer.writeStartElement("skl"); writer.writeStartElement("external-file"); writer.writeAttributeString("href", skeletonPath); writer.writeAttributeString("tool-id", params.getToolId()); writer.writeAttributeString("tool-name", params.getToolName()); writer.writeAttributeString("tool-version", params.getToolVersion()); if (!Util.isEmpty(params.getToolCompany())) writer.writeAttributeString("tool-company", params.getToolCompany());
writer.writeStartElement("alt-trans"); if ( segment != null ) { writer.writeAttributeString("mid", segment.getId()); writer.writeAttributeString("match-quality", String.format("%d", alt.getCombinedScore())); writer.writeAttributeString("origin", alt.getOrigin()); writer.writeAttributeString("okp:"+OKP_MATCHTYPE, alt.getType().toString()); writer.writeAttributeString("okp:"+OKP_ENGINE, alt.getEngine()); writer.writeAttributeString("xml:lang", alt.getSourceLocale().toBCP47()); writer.writeAttributeString("xml:lang", alt.getTargetLocale().toBCP47()); if ( params.getIncludeIts() ) { writeAnnotatorsRefIfNeeded();
xmlWriter.writeElementString("From", srcLang); xmlWriter.writeStartElement("Options"); xmlWriter.writeAttributeString("xmlns:o", "http://schemas.datacontract.org/2004/07/Microsoft.MT.Web.Service.V2"); xmlWriter.writeElementString("o:Category", category); xmlWriter.writeElementString("o:ContentType", contentType); xmlWriter.writeAttributeString("xmlns:s", "http://schemas.microsoft.com/2003/10/Serialization/Arrays"); for (String text : texts) { xmlWriter.writeStartElement("s:string");
writer.writeAttributeString("tuid", tuid); writer.writeAttributeString("tuid", String.format("%s_%s", tuid, srcSeg.id));
writer.writeAttributeString("xml:lang", locale.toBCP47()); if (isWriteAllPropertiesAsAttributes()) { Set<String> names; writer.writeAttributeString("type", name); writer.writeString(contForProp.getProperty(name).getValue());
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(); } }
XR.writeStartElement("omegat"); XR.writeStartElement("project"); XR.writeAttributeString("version", "1.0");