XMLをファイルに保存する。
@since 1.1
@param xmlInfo XML情報。
@param out
@throws XmlOperateException XMLの書き込みに失敗した場合。
@throws IllegalArgumentException xmlInfo is null.
@throws IllegalArgumentException writer is null.
542966
public static void save(final AnnotationMappingInfo xmlInfo, final OutputStream out) throws XmlOperateException {
        ArgUtils.notNull(xmlInfo, "xmlInfo");
        ArgUtils.notNull(out, "out");
        
        try {
            JAXB.marshal(xmlInfo, out);
            
        } catch (DataBindingException e) {
            throw new XmlOperateException("fail save xml with JAXB.", e);
        }
        
    }
1126124
public final void rewriteXml(
        Writer out,
        String xmlFile,
        String aloneTags[],
        boolean outputXmlHeader
    ) {
        try {
            DocumentBuilderFactory fact = CDocumentBuilderFactory.newParser();
            Document xmlDoc =
                fact.newDocumentBuilder()
                    .parse(new InputSource(new StringReader(xmlFile)));
            rewriteXml(
                out,
                xmlDoc,
                aloneTags,
                outputXmlHeader
            );
        } catch (Exception e) {
            e.printStackTrace();

            return;
        }
    }
1220420
public void write(Writer out)
            throws XmlModelWriterException, IOException
    {
        try
        {
            DOMSource domSource = new DOMSource(_doc);
            StreamResult streamResult = new StreamResult(out);
            TransformerFactory tf = TransformerFactory.newInstance();
            tf.setAttribute("indent-number", new Integer(INDENT_LEN));
            Transformer serializer = tf.newTransformer();
            if (_publicID != null) {
                serializer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, _publicID);
            }
            if (_systemID != null) {
                serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, _systemID);
            }
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.transform(domSource, streamResult);
        }
        catch (TransformerException e)
        {
            throw new XmlModelWriterException(e);
        }
    }
231285
public void dumpXml(PrintStream out) {
        out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
        out.println("<history>");
        String startData = "    <data ";
        String stop = "/>";
        for (int i = 0; i < versionList.length; ++i) {
            Version version = versionList[i];
            AppVersion appVersion = sequenceToAppVersionMap.get(version.getSequence());
            out.print("  <historyItem ");
            out.print("seq=\"");
            out.print(i);
            out.print("\" ");
            out.print("version=\"");
            out.print(appVersion != null ? appVersion.getReleaseName() : "");
            out.print("\" ");
            out.print("time=\"");
            if (formatDates) {
                out.print((appVersion != null ? new Date(appVersion.getTimestamp()).toString() : ""));
            } else {
                out.print(appVersion != null ? appVersion.getTimestamp() : 0L);
            }
            out.print("\"");
            out.println(">");

            String attributeName[] = new String[TUPLE_SIZE];
            attributeName[0] = "added";
            attributeName[1] = "newCode";
            attributeName[2] = "fixed";
            attributeName[3] = "removed";
            attributeName[4] = "retained";
            attributeName[5] = "dead";
            attributeName[6] = "active";
            for (int j = 0; j < TUPLE_SIZE; ++j) {
                // newCode and retained are already comprised within active
                // so we skip tehm
                if (j == 1 || j == 4) {
                    continue;
                }
                out.print(startData + " name=\"" + attributeName[j] + "\" value=\"");
                out.print(version.get(j));
                out.print("\"");
                out.println(stop);
            }
            out.println("  </historyItem>");
        }
        out.print("</history>");
    }
791689
protected void saveInternal(XMLStreamWriter stream) throws XMLStreamException {
        if (namespace != null) {
            stream.writeStartElement(prefix, namespace, name);
        } else {
            stream.writeStartElement(name);
        }
        for (Map.Entry<XAttributeName, String> a : attributes.entrySet()) {
            XAttributeName an = a.getKey();
            if (an.namespace != null) {
                stream.writeAttribute(an.prefix, an.namespace, an.name, a.getValue());
            } else {
                stream.writeAttribute(an.name, a.getValue());
            }
        }
        if (content != null) {
            stream.writeCharacters(content);
        } else {
            for (XNElement e : children) {
                e.saveInternal(stream);
            }
        }
        
        stream.writeEndElement();
    }
603157
public void xmlWriteOn(FormattedWriter writer) throws IOException
  {
    super.xmlWriteOn(writer);
    
    writer.newLine();
    writer.taggedValue("subscriberID", _subState.getSubscriberID());

    writer.newLine();
    writer.startTag("topics");
    writer.indent();

    String[] topics = _subState.getTopics();

    if (topics != null)
    {
      for (int i = 0; i < topics.length; i++)
      {
        writer.newLine();
        writer.taggedValue("topic", topics[i]);
      }
    }

    writer.outdent();
    writer.newLine();
    writer.endTag("topics");
    writer.newLine();
    writer.taggedValue("toBeDeleted", toBeDeleted);
  }
1250350
@Override
    public final void xmlRequestWriteOnSystemOut() throws IOException
    {
        FormattedWriter writer = new FormattedWriter(new OutputStreamWriter(System.out));
        xmlWriteOn(writer);
        writer.flush();
    }
184539
public void printXML(HttpServletRequest req, PrintWriter out)
    {
        ServletTask task = (ServletTask)this.getTask();
        Map<String,Object> properties = task.getRequestProperties(task.getServletRequest(), true);
        
        CreateWSDL wsdl = null;
        if ("2.0".equalsIgnoreCase(this.getProperty(WSDL_VERSION)))
            wsdl = new CreateWSDL20(task, null, properties);    // Default
        else    // 1.1 Is the default for now
            wsdl = new CreateWSDL11(task, null, properties);
        Object data = wsdl.createMarshallableObject();
        String xml = wsdl.getXML(data);
        out.println(xml);
        wsdl.free();
    }
927276
public void simpleFastWrite(Writer out)
            throws IOException, XmlModelWriterException
    {
        out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
        
        if (_publicID != null && _systemID != null) {
            out.write("<!DOCTYPE ");
            out.write(_rootName);
            out.write(" PUBLIC \"");
            out.write(_publicID);
            out.write("\" \"");
            out.write(_systemID);
            out.write("\">\n");
        }
        
        writeElement(out, _doc.getDocumentElement(), 0);
    }
65251
public static void writeFile(final Document input, final File output) {
        final StreamResult result = new StreamResult(new StringWriter());

        format(new DOMSource(input), result);

        try {
            new FileWriter(output).write(result.getWriter().toString());
        } catch (final IOException ioEx) {
            LOGGER.error("Problem writing XML to file.", ioEx);
        }
    }
1157747
@Override
   public void writeXmlBody(Definition def, Writer out) throws IOException
   {
      writeConnectorVersion(out);

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

      if (def.isUseRa())
      {
         writeIndent(out, indent + 1);
         out.write("<resourceadapter-class>" + def.getRaPackage() + "." +
               def.getRaClass() + "</resourceadapter-class>");
         writeEol(out);
         writeConfigPropsXml(def.getRaConfigProps(), out, indent + 1);
      }

      if (def.isSupportOutbound())
      {
         writeOutbound(def, out, indent + 1);
      }
      if (def.isSupportInbound())
      {
         writeInbound(def, out, indent + 1);
      }

      if (def.isGenAdminObject() && def.getAdminObjects().size() > 0)
      {
         for (int i = 0; i < def.getAdminObjects().size(); i++)
         {
            writeIndent(out, indent + 1);
            out.write("<adminobject>");
            writeEol(out);
            writeIndent(out, indent + 2);
            out.write("<adminobject-interface>" + def.getRaPackage() + "." +
                  def.getAdminObjects().get(i).getAdminObjectInterface() + "</adminobject-interface>");
            writeEol(out);
            writeIndent(out, indent + 2);
            out.write("<adminobject-class>" + def.getRaPackage() + "." +
                  def.getAdminObjects().get(i).getAdminObjectClass() + "</adminobject-class>");
            writeEol(out);
            writeConfigPropsXml(def.getAdminObjects().get(i).getAoConfigProps(), out, indent + 2);
            writeIndent(out, indent + 1);
            out.write("</adminobject>");
            writeEol(out);
         }
      }

      if (def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
      {
         for (int i = 0; i < def.getSecurityPermissions().size(); i++)
         {
            writeIndent(out, indent + 1);
            out.write("<security-permission>");
            writeEol(out);
            writeIndent(out, indent + 2);
            out.write("<security-permission-spec>" + def.getSecurityPermissions().get(i).getPermissionSpec() +
                  "</security-permission-spec>");
            writeEol(out);
            writeIndent(out, indent + 1);
            out.write("</security-permission>");
            writeEol(out);
         }
      }

      writeIndent(out, indent);
      out.write("</resourceadapter>");
      writeEol(out);
      out.write("</connector>");
      writeEol(out);
   }
496358
public static void saveReport(String xml, String path) {
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream(path);
			fos.write(xml.getBytes("UTF-8"));
			fos.flush();
		} catch (Exception ex) {
			LOG.error(ex.getMessage(), ex);
			ex.printStackTrace();
		} finally {
			if (fos != null) {
				try {
					fos.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
626883
public void xmlWriteOn(FormattedWriter writer) throws IOException
    {
        writer.newLine();
        writer.startTag(XML_ITEM_MAP);
        writer.indent();
        for (int i = 0; null != _entry && i < _entry.length; i++) // 666212
        {
            AbstractItemLink ail = _entry[i];
            while (null != ail)
            {
                writer.newLine();
                ail.xmlShortWriteOn(writer);
                ail = ail.getNextMappedLink();
            }
        }
        writer.outdent();
        writer.newLine();
        writer.endTag(XML_ITEM_MAP);
    }
355228
public void save(XMLStreamWriter stream) throws XMLStreamException {
        stream.writeStartDocument("UTF-8", "1.0");
        
        saveInternal(stream);
        
        stream.writeEndDocument();
    }
350797
public final String rewriteXml(
        Node xmlDoc,
        String aloneTags[],
        boolean outputXmlHeader
    ) {
        try {
            StringWriter sOut = new StringWriter();
            rewriteXml(
                sOut,
                xmlDoc,
                aloneTags,
                outputXmlHeader
            );

            return sOut.toString();
        } catch (Exception e) {
            e.printStackTrace();

            return null;
        }
    }
322185
public void writeXML(OutputStream outputStream, String encoding, String indent, String lineSeparator)
  throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setEncoding(encoding);
    format.setIndent(indent);
    format.setLineSeparator(lineSeparator);
    outputter.setFormat(format);
    outputter.output(getDocument(), outputStream);
  }
695228
protected XMLStreamWriter createStreamWriter(OutputStream output) throws XMLStreamException {
        if (outputFactory == null) {
            outputFactory = XMLOutputFactory.newInstance();
        }
        return outputFactory.createXMLStreamWriter(output);
    }