Returns the sorted xml as an OutputStream.

@return the sorted xml
2131
public String getSortedXml(Document newDocument) {
        try (ByteArrayOutputStream sortedXml = new ByteArrayOutputStream()) {
            BufferedLineSeparatorOutputStream bufferedLineOutputStream =
                    new BufferedLineSeparatorOutputStream(lineSeparatorUtil.toString(), sortedXml);

            XMLOutputter xmlOutputter = new PatchedXMLOutputter(bufferedLineOutputStream, indentBlankLines);
            xmlOutputter.setFormat(createPrettyFormat());
            xmlOutputter.output(newDocument, bufferedLineOutputStream);

            bufferedLineOutputStream.close();
            return sortedXml.toString(encoding);
        } catch (IOException ioex) {
            throw new FailureException("Could not format pom files content", ioex);
        }
    }
1180675
public LongStreamEx reverseSorted() {
        LongUnaryOperator inv = x -> ~x;
        return new LongStreamEx(stream().map(inv).sorted().map(inv), context);
    }
1330375
public OutputStream getOutputStream()
    throws IOException
  {
    if (_os == null)
      _os = new FileOutputStream(_file.getFD());

    return _os;
  }
286212
public OutputStream getRequestOutputStream()
        throws IOException, IllegalStateException {
        LOG.trace("enter HttpConnection.getRequestOutputStream()");
        assertOpen();
        OutputStream out = this.outputStream;
        if (Wire.CONTENT_WIRE.enabled()) {
            out = new WireLogOutputStream(out, Wire.CONTENT_WIRE);
        }
        return out;
    }
551584
public @Nonnull Stream<XQuery> stream() {
        return new NodeListSpliterator(node.getChildNodes()).stream()
                        .filter(it -> it instanceof Element)
                        .map(XQuery::new);
    }
11635
private String sortXml(final String originalXml) {

        xmlProcessingInstructionParser.scanForIgnoredSections(originalXml);
        String xml = xmlProcessingInstructionParser.replaceIgnoredSections();

        insertXmlInXmlProcessor(xml, () -> "Could not sort " + pomFile.getAbsolutePath() + " content: ");
        xmlProcessor.sortXml();
        Document newDocument = xmlProcessor.getNewDocument();

        String sortedXml = xmlOutputGenerator.getSortedXml(newDocument);
        if (xmlProcessingInstructionParser.existsIgnoredSections()) {
            sortedXml = xmlProcessingInstructionParser.revertIgnoredSections(sortedXml);
        }
        return sortedXml;
    }
819180
protected OutputStream createStagingFileOutputStream()
      throws IOException {
    OutputStream out = this.fs
        .create(this.stagingFile, this.filePermission, true, this.bufferSize, this.replicationFactor, this.blockSize,
            null);

    // encoders need to be attached to the stream in reverse order since we should write to the
    // innermost encoder first
    for (StreamCodec encoder : Lists.reverse(getEncoders())) {
      out = encoder.encodeOutputStream(out);
    }

    return this.closer.register(out);
  }
313590
public Result xml() {
        setContentType(MimeTypes.XML);
        charset = Charsets.UTF_8;
        // If we already have a String content, we must set the type.
        // The renderable object checks whether or not the given String is a valid XML string,
        // or if a transformation is required.
        if (getRenderable() instanceof RenderableString) {
            ((RenderableString) getRenderable()).setType(MimeTypes.XML);
        }
        return this;
    }
222144
public StreamSource getTransformerStream()
    {
        Reader reader = new StringReader(XSL_CONVERT);
        StreamSource stylesource = new StreamSource(reader);
        return stylesource;
    }
572141
public static XMLStreamWriter getIndentingXmlStreamWriter(Writer writer) throws XMLStreamException, IOException {
        XMLOutputFactory f = XMLOutputFactory.newInstance();
        return new IndentingXMLStreamWriter(f.createXMLStreamWriter(writer));
    }
567961
@Override
    public InputStream GetObjectXML() throws ObjectIntegrityException,
                                             StreamIOException, UnsupportedTranslationException, ServerException {
        ReadableByteArrayOutputStream bytes = new ReadableByteArrayOutputStream(4096);
        m_translator.serialize(m_obj,
                               bytes,
                               m_storageFormat,
                               "UTF-8",
                               DOTranslationUtility.SERIALIZE_STORAGE_INTERNAL);
        return bytes.toInputStream();
    }
1169364
public String toXML()
    {
        String eol = System.getProperty("line.separator");
        RepositoryTags tags = RepositoryTags.getInstance();

        // The result
        String result = "     ";

        switch (this.fieldSource)
        {
            case SOURCE_FIELD :
                result += " " + tags.getOpeningTagNonClosingById(RUNTIME_ARGUMENT);
                result += " " + tags.getAttribute(FIELD_REF, this.fieldRefName);
                result += " " + tags.getAttribute(RETURN, String.valueOf(this.returnedByProcedure));
                result += "/>";
                break;
            case SOURCE_VALUE :
                result += " " + tags.getOpeningTagNonClosingById(CONSTANT_ARGUMENT);
                result += " " + tags.getAttribute(VALUE, this.constantValue);
                result += "/>";
                break;
            case SOURCE_NULL :
                result += " " + tags.getOpeningTagNonClosingById(RUNTIME_ARGUMENT);
                result += "/>";
                break;
            default :
                break;
        }

        // Return the result.
        return (result + eol);
    }
1037888
public byte[] serializeDoc() throws IOException {
		XmlDomWriter xw = new XmlDomWriter();
        ByteArrayOutputStream fout = new ByteArrayOutputStream();
        xw.setOutput(fout, null);
        fout.write(XmpWriter.XPACKET_PI_BEGIN.getBytes("UTF-8"));
        fout.flush();
        NodeList xmpmeta = domDocument.getElementsByTagName("x:xmpmeta");
        xw.write(xmpmeta.item(0));
        fout.flush();
		for (int i = 0; i < 20; i++) {
			fout.write(XmpWriter.EXTRASPACE.getBytes());
		}
        fout.write(XmpWriter.XPACKET_PI_END_W.getBytes());
        fout.close();
        return fout.toByteArray();
	}
184520
@Override
  public ODocument toStream() {
    acquireExclusiveLock();
    try {
      document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING);

      try {
        final ORecordTrackedSet idxs = new ORecordTrackedSet(document);

        for (final OIndexInternal<?> i : indexes.values()) {
          idxs.add(i.updateConfiguration());
        }
        document.field(CONFIG_INDEXES, idxs, OType.EMBEDDEDSET);

      } finally {
        document.setInternalStatus(ORecordElement.STATUS.LOADED);
      }
      document.setDirty();

      return document;
    } finally {
      releaseExclusiveLock();
    }
  }
649419
public String getStreamHeader() {
    StringBuilder builder = new StringBuilder();
    builder.append("GDAT").append(Constants.NEWLINE).append("VERSION:").append(VERSION).append(Constants.NEWLINE)
      .append("SCHEMALENGTH:");
    String streamTree = getStreamParseTree();
    int headerLength = streamTree.length();
    builder.append(Integer.toString(headerLength));
    builder.append(Constants.NEWLINE);
    builder.append(streamTree);
    return builder.toString();
  }
240837
public String getXmlStreamInfo()
	{
		StringBuilder sb = new StringBuilder();

		int event = r.getEventType();
		if (event == START_ELEMENT || event == END_ELEMENT || event == ENTITY_REFERENCE)
		{
			sb.append(r.getLocalName());
		}

		if (r.getLocation() != null)
		{
			sb.append(" line ");
			sb.append(r.getLocation().getLineNumber());
			sb.append(" column ");
			sb.append(r.getLocation().getColumnNumber());
		}

		return sb.toString();
	}
481176
public static StreamingOutput createStream(final Document doc) {
        return new StreamingOutput() {

            @Override
            public void write(final OutputStream output) {
                synchronized (output) {
                    final DOMSource domSource = new DOMSource(doc);
                    final StreamResult streamResult = new StreamResult(output);
                    Transformer transformer;
                    try {
                        transformer = TransformerFactory.newInstance().newTransformer();
                        transformer.transform(domSource, streamResult);
                    } catch (final TransformerException exc) {
                        exc.printStackTrace();
                        throw new JaxRxException(exc);
                    }

                }
            }
        };
    }