gpt4 book ai didi

net.sf.okapi.common.XMLWriter.writeAttributeString()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-27 05:25:05 31 4
gpt4 key购买 nike

本文整理了Java中net.sf.okapi.common.XMLWriter.writeAttributeString()方法的一些代码示例,展示了XMLWriter.writeAttributeString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLWriter.writeAttributeString()方法的具体详情如下:
包路径:net.sf.okapi.common.XMLWriter
类名称:XMLWriter
方法名:writeAttributeString

XMLWriter.writeAttributeString介绍

[英]Writes an attribute and its associated value. You must use #writeStartElement(String) just before.
[中]写入属性及其关联值。您必须在之前使用#WriteStarteElement(字符串)。

代码示例

代码示例来源:origin: net.sf.okapi/okapi-core

private void writeAnnotatorsRefIfNeeded () {
  if ( needAnnotatorsRef && params.getIncludeIts() ) {
    writer.writeAttributeString(Namespaces.ITS_NS_PREFIX+":annotatorsRef", annotatorsRef.peek());
    needAnnotatorsRef = false;
  }
}

代码示例来源:origin: net.sf.okapi/okapi-core

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());
    }
  }
}

代码示例来源:origin: net.sf.okapi/okapi-core

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());
    }
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-gttbatchtranslation

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);
  }
}

代码示例来源:origin: net.sf.okapi/okapi-core

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
  }
}

代码示例来源:origin: net.sf.okapi/okapi-core

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");
    }
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-leveraging

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;
}

代码示例来源:origin: net.sf.okapi/okapi-core

/**
 * Writes the start of a &lt;group&gt; 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();
}

代码示例来源:origin: net.sf.okapi/okapi-core

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");

代码示例来源:origin: net.sf.okapi.lib/okapi-lib-segmentation

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"));

代码示例来源:origin: net.sf.okapi/okapi-core

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
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-gttbatchtranslation

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 {

代码示例来源:origin: net.sf.okapi/okapi-core

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));

代码示例来源:origin: net.sf.okapi/okapi-core

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());

代码示例来源:origin: net.sf.okapi/okapi-core

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();

代码示例来源:origin: net.sf.okapi.connectors/okapi-connector-microsoft

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");

代码示例来源:origin: net.sf.okapi/okapi-core

writer.writeAttributeString("tuid", tuid);
writer.writeAttributeString("tuid", String.format("%s_%s", tuid, srcSeg.id));

代码示例来源:origin: net.sf.okapi/okapi-core

writer.writeAttributeString("xml:lang", locale.toBCP47());
if (isWriteAllPropertiesAsAttributes()) {
  Set<String> names;
      writer.writeAttributeString("type", name);
      writer.writeString(contForProp.getProperty(name).getValue());

代码示例来源:origin: net.sf.okapi.connectors/okapi-connector-microsoft

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();
  }
}

代码示例来源:origin: net.sf.okapi.steps/okapi-step-rainbowkit

XR.writeStartElement("omegat");
XR.writeStartElement("project");
XR.writeAttributeString("version", "1.0");

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com