/*
(non-Javadoc)

@see
edu.umd.cs.findbugs.xml.XMLWriteable#writeXML(edu.umd.cs.findbugs.xml
.XMLOutput)
480648
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.openCloseTag("Property",
                new XMLAttributeList().addAttribute("name", getName()).addAttribute("value", getValue()));
    }
1001572
public final void xmlRequestWriteRawDataOnSystemOut() throws IOException
    {
        FormattedWriter writer = new FormattedWriter(new OutputStreamWriter(System.out));
        xmlWriteRawOn(writer, false);
        writer.flush();
    }
865195
def writeXMLFile(filename, content):
    
    xmlfile = open(filename, 'w')
    # pretty print
    content = etree.tostring(content, pretty_print=True)
    xmlfile.write(content)
    xmlfile.close()
620725
public void writeMapToXML(final Map<String, Set<String>> m) {
        final File outputFile = new File(job.tempDir, FILE_NAME_PLUGIN_XML);
        if (m == null) {
            return;
        }
        final Properties prop = new Properties();
        for (Map.Entry<String, Set<String>> entry : m.entrySet()) {
            final String key = entry.getKey();
            final String value = StringUtils.join(entry.getValue(),
                    COMMA);
            prop.setProperty(key, value);
        }
        //File outputFile = new File(tempDir, filename);

        final DocumentBuilder db = XMLUtils.getDocumentBuilder();
        final Document doc = db.newDocument();
        final Element properties = (Element) doc.appendChild(doc
                .createElement("properties"));

        final Set<Object> keys = prop.keySet();
        for (Object key1 : keys) {
            final String key = (String) key1;
            final Element entry = (Element) properties.appendChild(doc
                    .createElement("entry"));
            entry.setAttribute("key", key);
            entry.appendChild(doc.createTextNode(prop.getProperty(key)));
        }
        final TransformerFactory tf = TransformerFactory.newInstance();
        Transformer t;
        try {
            t = withLogger(tf.newTransformer(), logger);
            t.setOutputProperty(OutputKeys.INDENT, "yes");
            t.setOutputProperty(OutputKeys.METHOD, "xml");
            t.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        } catch (final TransformerConfigurationException tce) {
            throw new RuntimeException(tce);
        }
        final DOMSource doms = new DOMSource(doc);
        OutputStream out = null;
        try {
            out = new FileOutputStream(outputFile);
            final StreamResult sr = new StreamResult(out);
            t.transform(doms, sr);
        } catch (final Exception e) {
            logger.error("Failed to process map: " + e.getMessage(), e);
        } finally {
            if (out != null) {
                try {
                    out.close();
                } catch (final IOException e) {
                    logger.error("Failed to close output stream: " + e.getMessage());
                }
            }
        }
    }
1241582
def WriteXml(self, w, option, elementName=None):
		
		if elementName == None:
			x = w.createElement(self.propMoMeta.xmlAttribute)
		else:
			x = w.createElement(elementName)
		for at in UcsUtils.GetUcsPropertyMetaAttributeList(self.classId):
			atMeta = UcsUtils.GetUcsMethodMeta(self.classId, at)
			if (atMeta.io == "Output"):
				continue
			if atMeta.isComplexType:
				if (getattr(self, at) != None):
					x.appendChild(self.__dict__[at].WriteXml(w, option, UcsUtils.WordL(at)))
			elif (getattr(self, at) != None):
				x.setAttribute(atMeta.xmlAttribute, getattr(self, at))
		x_child = self.childWriteXml(w, option)
		for xc in x_child:
			if (xc != None):
				x.appendChild(xc)
		return x
1250350
@Override
    public final void xmlRequestWriteOnSystemOut() throws IOException
    {
        FormattedWriter writer = new FormattedWriter(new OutputStreamWriter(System.out));
        xmlWriteOn(writer);
        writer.flush();
    }
193911
public static boolean WriteXml(ExcelConfig dlExcel, String xmlPath) throws Exception {
        //写入xml
        return XmlUtil.toXml(dlExcel, new File(xmlPath));
    }
408611
public static void serializeXMLDocument (Document doc, Writer output) throws TransformerException {
        // serialize XML document using identity transformation
        Transformer trans = TransformerFactory.newInstance().newTransformer();
        DOMSource source = new DOMSource(doc);
        StreamResult result = new StreamResult(output);
        trans.transform(source, result);
    }
965610
@Override
    public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        super.xmlWriteOn(writer);
        writer.newLine();
        writer.taggedValue("toBeDeleted", _toBeDeleted);
        writer.newLine();
        writer.taggedValue("toBeIgnored", _toBeIgnored);
    }
851257
public void xmlWriteOn(FormattedWriter writer) throws IOException  
  {
    writer.newLine();
    writer.taggedValue("name", definition.getName());
    writer.newLine();
    writer.taggedValue("uuid", definition.getUUID());
  }
889916
@Override
    public void writeXML(@WillClose XMLOutput xmlOutput) throws IOException {
        assert project != null;
        try {
            writePrologue(xmlOutput);
            if (withMessages) {
                computeBugHashes();
                getProjectStats().computeFileStats(this);
                String commonBase = null;
                for (String s : project.getSourceDirList()) {
                    if (commonBase == null) {
                        commonBase = s;
                    } else {
                        commonBase = commonBase.substring(0, commonPrefix(commonBase, s));
                    }

                }
                if (commonBase != null && commonBase.length() > 0) {
                    if (commonBase.indexOf("/./") > 0) {
                        commonBase = commonBase.substring(0, commonBase.indexOf("/."));
                    }
                    File base = new File(commonBase);
                    if (base.exists() && base.isDirectory() && base.canRead()) {
                        SourceLineAnnotation.generateRelativeSource(base, project);
                    }
                }
            }
            if (earlyStats && !minimalXML) {
                getProjectStats().writeXML(xmlOutput, withMessages);
            }

            // Write BugInstances
            for (BugInstance bugInstance : getCollection()) {
                if (!applySuppressions || !project.getSuppressionFilter().match(bugInstance)) {
                    bugInstance.writeXML(xmlOutput, this, withMessages);
                }
            }

            writeEpilogue(xmlOutput);

        } finally {
            xmlOutput.finish();
            SourceLineAnnotation.clearGenerateRelativeSource();
        }
    }
844528
@Override
   public void writeXmlBody(Definition def, Writer out) throws IOException
   {
      writeConnectorVersion(out);

      int indent = 1;
      writeIndent(out, indent);
      out.write("<display-name>Display Name</display-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<vendor-name>Red Hat Inc</vendor-name>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<spec-version>1.0</spec-version>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<eis-type>Test RA</eis-type>");
      writeEol(out);
      writeIndent(out, indent);
      out.write("<version>0.1</version>");
      writeEol(out);

      writeIndent(out, indent);
      out.write("<resourceadapter>");
      writeEol(out);

      writeOutbound(def, out, indent + 1);

      writeIndent(out, indent);
      out.write("</resourceadapter>");
      writeEol(out);
      out.write("</connector>");
      writeEol(out);
   }
300765
public void writeXsd(final OutputStream out) {

    SchemaOutputResolver sor = new SchemaOutputResolver() {

      @Override
      public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {

        StreamResult streamResult = new StreamResult(out);
        streamResult.setSystemId(suggestedFileName);
        return streamResult;
      }

    };
    try {
      this.jaxbContext.generateSchema(sor);
    } catch (IOException e) {
      throw new IllegalStateException("Failed to generate and write the XSD schema!", e);
    }
  }
1368445
public final void xmlWriteOn(FormattedWriter writer, String tagName) throws IOException
    {
        Link link = getHead();
        if (link != null)
        {
            writer.newLine();
            writer.startTag(tagName);
            writer.indent();

            while (link != null)
            {
                writer.newLine();
                link.xmlWriteOn(writer);
                link = link.getNextPhysicalLink();
            }

            writer.outdent();
            writer.newLine();
            writer.endTag(tagName);
        }
    }
519045
public final void rewriteXml(
        Writer out,
        String xmlFile,
        String aloneTags[]
    ) {
        rewriteXml(
            out,
            xmlFile,
            aloneTags,
            false
        );
    }
454661
def writeXML(self, e):
        
        self.writeType(TYPE_XML)

        data = xml.tostring(e)

        if isinstance(data, unicode):
            data = data.encode('utf-8')

        self.stream.write_ulong(len(data))
        self.stream.write(data)
1246354
@Override
    public void writeXML(XMLOutput xmlOutput) throws IOException {
        xmlOutput.startTag("FindBugsProfile");
        xmlOutput.stopTag(false);
        TreeSet<Class<?>> treeSet = new TreeSet<>(new TotalTimeComparator(this));
        treeSet.addAll(profile.keySet());
        long totalTime = 0;
        for (Profile p : profile.values()) {
            totalTime += p.totalTime.get();
        }

        long accumulatedTime = 0;

        for (Class<?> c : treeSet) {
            Profile p = getProfile(c);
            if (p == null) {
                continue;
            }
            p.writeXML(xmlOutput);
            accumulatedTime += p.totalTime.get();
            if (accumulatedTime > 3 * totalTime / 4) {
                break;
            }
        }
        xmlOutput.closeTag("FindBugsProfile");
    }