class TraxUtils {

	public static Document getDocument(DOMSource source) {
		Node node = source.getNode();
		if (node instanceof Document) {
			return (Document) node;
		} else if (node != null) {
			return node.getOwnerDocument();
		} else {
			return null;
		}
	}

}