protected void printDocType(final SAXTarget out, final FormatStack fstack,
			final DocType docType) throws SAXException {

		// Fire DTD-related events only if handlers have been registered.
		final DTDHandler dtdHandler = out.getDTDHandler();
		final DeclHandler declHandler = out.getDeclHandler();
		if ((docType != null)
				&& ((dtdHandler != null) || (declHandler != null))) {

			// Build a dummy XML document that only references the DTD...
			String dtdDoc = new XMLOutputter().outputString(docType);

			try {
				// And parse it to fire DTD events.
				createDTDParser(out).parse(
						new InputSource(new StringReader(dtdDoc)));

				// We should never reach this point as the document is
				// ill-formed; it does not have any root element.
			} catch (SAXParseException e) {
				// Expected exception: There's no root element in document.
			} catch (IOException e) {
				throw new SAXException("DTD parsing error", e);
			}
		}

	}