gpt4 book ai didi

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

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

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

XMLWriter.writeStartElement介绍

[英]Writes the start of an element.
[中]写入元素的开头。

代码示例

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

@Override
protected void startWriting(OutputStream outStream) {		
  //this.outStream = outStream;
  prWriter = new PrintWriter(outStream);
  writer = new XMLWriter(prWriter);
  writer.writeStartDocument();
  writer.writeStartElement("body");
  writer.writeLineBreak();
}

代码示例来源: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.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.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/okapi-core

writer.writeStartElement("tu");
if ( !Util.isEmpty(tuid) ) {
  writer.writeAttributeString("tuid", tuid);
  writer.writeStartElement("prop");
  writer.writeAttributeString("type", name);
  writer.writeString(attributes.get(name));
writer.writeStartElement("tuv");
writer.writeAttributeString("xml:lang", srcLoc.toBCP47());
writer.writeStartElement("seg");
writer.writeRawXML(tmxCont.setContent(source).toString());
  writer.writeStartElement("tuv");
    writer.writeAttributeString("xml:lang",
      ((altTrgLoc != null) ? altTrgLoc.toBCP47() : trgLoc.toBCP47()));
    writer.writeAttributeString(CREATIONID, attributes.get(CREATIONID));
  writer.writeStartElement("seg");
  writer.writeRawXML(tmxCont.setContent(target).toString());

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

writer.writeStartElement("html"); //$NON-NLS-1$
writer.writeStartElement("head"); //$NON-NLS-1$
writer.writeRawXML("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />"); //$NON-NLS-1$
writer.writeRawXML("<style>td { font-family: monospace } td { vertical-align: top; white-space: pre } td.p { border-top-style: solid; border-top-width: 1px;}</style>"); //$NON-NLS-1$
writer.writeStartElement("body"); //$NON-NLS-1$
writer.writeStartElement("h1"); //$NON-NLS-1$
writer.writeString("Translation Comparison");
writer.writeEndElement();
writer.writeStartElement("p"); //$NON-NLS-1$
writer.writeString(String.format("Base document (%s): %s",
  params.getDocument1Label(), baseDocumentPath));
  +"<a href='"+WIKIURL+"'>"+WIKIURL+"</a>.</p>");
writer.writeRawXML("<p><a href='#summary'>Go to Summary</a></p>");
writer.writeStartElement("table"); //$NON-NLS-1$

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

htmlWriter.writeStartElement("p");
String out = String.format("%d:%s:%s", subDocId, tu.getId(), seg.id);
count += (out.length() + 10);

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

XMLWriter xmlWriter = new XMLWriter(sw);
xmlWriter.writeStartDocument();
xmlWriter.writeStartElement("GetTranslationsArrayRequest");
xmlWriter.writeElementString("AppId", "");
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:User", "");
xmlWriter.writeStartElement("Texts");
xmlWriter.writeAttributeString("xmlns:s", "http://schemas.microsoft.com/2003/10/Serialization/Arrays");
for (String text : texts) {
  xmlWriter.writeStartElement("s:string");
  xmlWriter.writeString(text);
  xmlWriter.writeEndElement();

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

XR = new XMLWriter(projectSaveFile);
XR.writeStartDocument();
XR.writeStartElement("omegat");
XR.writeStartElement("project");
XR.writeAttributeString("version", "1.0");
XR.writeStartElement("source_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeStartElement("target_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeStartElement("tm_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeStartElement("glossary_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeStartElement("dictionary_dir");
XR.writeRawXML("__DEFAULT__");
XR.writeStartElement("source_lang");
XR.writeRawXML(manifest.getSourceLocale().toString());
XR.writeStartElement("target_lang");
XR.writeRawXML(manifest.getTargetLocale().toString());
XR.writeStartElement("sentence_seg");

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

TextContainer contForProp)
writer.writeStartElement("tuv");
writer.writeAttributeString("xml:lang", locale.toBCP47());
if (isWriteAllPropertiesAsAttributes()) {
      writer.writeStartElement("prop");
      writer.writeAttributeString("type", name);
      writer.writeString(contForProp.getProperty(name).getValue());
writer.writeStartElement("seg");
writer.writeRawXML(tmxCont.setContent(frag).toString());

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

writer.writeStartElement("srx");
writer.writeAttributeString("xmlns", NSURI_SRX20);
if (saveExtensions) {
writer.writeStartElement("header");
writer.writeAttributeString("segmentsubflows", (segmentSubFlows ? "yes" : "no"));
writer.writeAttributeString("cascade", (cascade ? "yes" : "no"));
writer.writeLineBreak();
writer.writeStartElement("formathandle");
writer.writeAttributeString("type", "start");
writer.writeAttributeString("include", (includeStartCodes ? "yes" : "no"));
writer.writeStartElement("formathandle");
writer.writeAttributeString("type", "end");
writer.writeAttributeString("include", (includeEndCodes ? "yes" : "no"));
writer.writeStartElement("formathandle");
writer.writeAttributeString("type", "isolated");
writer.writeAttributeString("include", (includeIsolatedCodes ? "yes" : "no"));
  writer.writeStartElement(NSPREFIX_OKPSRX + ":options");
  writer.writeAttributeString("oneSegmentIncludesAll", (oneSegmentIncludesAll ? "yes" : "no"));
  writer.writeAttributeString("trimLeadingWhitespaces", (trimLeadingWS ? "yes" : "no"));
  writer.writeStartElement(NSPREFIX_OKPSRX + ":sample");
  writer.writeAttributeString("language", getSampleLanguage());
  writer.writeAttributeString("useMappedRules", (testOnSelectedGroup() ? "no" : "yes"));

代码示例来源: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

String extraForHeader)
writer.writeStartElement("file");
writer.writeAttributeString("original",
  (original!=null) ? original : "unknown");
  writer.writeStartElement("header");			
    writer.writeStartElement("skl");
    writer.writeStartElement("external-file");
    writer.writeAttributeString("href", skeletonPath);
    writer.writeStartElement("tool");
    writer.writeAttributeString("tool-id", params.getToolId());
    writer.writeAttributeString("tool-name", params.getToolName());
writer.writeStartElement("body");
writer.writeLineBreak();

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

writer.writeStartElement("tu");
if ( srcCont.contentIsOneSegment() ) {
  writer.writeAttributeString("tuid", tuid);

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

htmlWriter.writeStartElement("p");
htmlWriter.writeAttributeString("id", String.format("%d:%s:%s", currentSubDocId, tu.getId(), seg.id));
htmlWriter.writeRawXML(qutil.toCodedHTML(seg.text));

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

if ( itemCount > 0 ) {
  writer.writeStartElement("h2"); //$NON-NLS-1$
  writer.writeAttributeString("id", "summary");
  writer.writeString("Summary");
  writer.writeElementString("p", " ");
  writer.writeStartElement("table"); //$NON-NLS-1$

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

writer.writeStartElement("xliff");
writer.writeAttributeString("version", "1.2");
writer.writeAttributeString("xmlns", Namespaces.NS_XLIFF12);

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

writer.writeStartElement("alt-trans");
if ( segment != null ) {
  writer.writeAttributeString("mid", segment.getId());
  writer.writeStartElement("source");
  writer.writeAttributeString("xml:lang", alt.getSourceLocale().toBCP47());
writer.writeStartElement("target");
writer.writeAttributeString("xml:lang", alt.getTargetLocale().toBCP47());
if ( params.getIncludeIts() ) {

代码示例来源: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
  }
}

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