Returns a Document for a JAXBElement

@param jaxbElement
JAXB representation of an XML Element
@param prettyPrint
True for pretty print, otherwise false
@return The Document representation
337339
public static Document toDocument(JAXBElement<?> jaxbElement,
			boolean prettyPrint) {

		Document document = null;

		try {
			DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
					.newInstance();
			documentBuilderFactory.setNamespaceAware(true);
			documentBuilderFactory.setIgnoringElementContentWhitespace(true);
			documentBuilderFactory.isIgnoringComments();
			documentBuilderFactory.setCoalescing(true);

			document = documentBuilderFactory.newDocumentBuilder()
					.newDocument();

			String packName = jaxbElement.getDeclaredType().getPackage().getName();
			JAXBContext jaxbContext;
			if (packName.startsWith("org.mitre")){
				jaxbContext = stixJaxbContext();
			} else {
				jaxbContext = JAXBContext.newInstance(packName);
			}

			Marshaller marshaller = jaxbContext.createMarshaller();

			marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
					prettyPrint);

			marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");

			try {
				marshaller.marshal(jaxbElement, document);
			} catch (JAXBException e) {
				// otherwise handle non-XMLRootElements
				QName qualifiedName = new QName(
						STIXSchema.getNamespaceURI(jaxbElement), jaxbElement
								.getClass().getSimpleName());

				@SuppressWarnings({ "rawtypes", "unchecked" })
				JAXBElement root = new JAXBElement(qualifiedName,
						jaxbElement.getClass(), jaxbElement);

				marshaller.marshal(root, document);
			}

			removeUnusedNamespaces(document);

		} catch (ParserConfigurationException e) {
			throw new RuntimeException(e);
		} catch (JAXBException e) {
			throw new RuntimeException(e);
		}

		return document;
	}
387436
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "filter", scope = GetAllVersions.class)
	public JAXBElement<String> createGetAllVersionsFilter(String value) {
		return new JAXBElement<String>(_GetPropertiesFilter_QNAME,
				String.class, GetAllVersions.class, value);
	}
794184
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "includeACL", scope = GetObject.class)
	public JAXBElement<Boolean> createGetObjectIncludeACL(Boolean value) {
		return new JAXBElement<Boolean>(
				_GetObjectOfLatestVersionIncludeACL_QNAME, Boolean.class,
				GetObject.class, value);
	}
249816
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "overwriteFlag", scope = SetContentStream.class)
	public JAXBElement<Boolean> createSetContentStreamOverwriteFlag(
			Boolean value) {
		return new JAXBElement<Boolean>(_SetContentStreamOverwriteFlag_QNAME,
				Boolean.class, SetContentStream.class, value);
	}
1078673
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "typeId", scope = GetObjectRelationships.class)
	public JAXBElement<String> createGetObjectRelationshipsTypeId(String value) {
		return new JAXBElement<String>(_GetTypeChildrenTypeId_QNAME,
				String.class, GetObjectRelationships.class, value);
	}
221574
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "includeAllowableActions", scope = GetObjectParents.class)
	public JAXBElement<Boolean> createGetObjectParentsIncludeAllowableActions(
			Boolean value) {
		return new JAXBElement<Boolean>(
				_GetObjectOfLatestVersionIncludeAllowableActions_QNAME,
				Boolean.class, GetObjectParents.class, value);
	}
768475
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "renditionFilter", scope = GetObject.class)
	public JAXBElement<String> createGetObjectRenditionFilter(String value) {
		return new JAXBElement<String>(
				_GetObjectOfLatestVersionRenditionFilter_QNAME, String.class,
				GetObject.class, value);
	}
553163
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "includeAllowableActions", scope = GetCheckedOutDocs.class)
	public JAXBElement<Boolean> createGetCheckedOutDocsIncludeAllowableActions(
			Boolean value) {
		return new JAXBElement<Boolean>(
				_GetObjectOfLatestVersionIncludeAllowableActions_QNAME,
				Boolean.class, GetCheckedOutDocs.class, value);
	}
796278
@XmlElementDecl(namespace = "http://www.opengis.net/citygml/relief/2.0", name = "_GenericApplicationPropertyOfReliefFeature")
    public JAXBElement<Object> create_GenericApplicationPropertyOfReliefFeature(Object value) {
        return new JAXBElement<Object>(__GenericApplicationPropertyOfReliefFeature_QNAME, Object.class, null, value);
    }
601492
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "filter", scope = GetObject.class)
	public JAXBElement<String> createGetObjectFilter(String value) {
		return new JAXBElement<String>(_GetPropertiesFilter_QNAME,
				String.class, GetObject.class, value);
	}
873637
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "orderBy", scope = GetChildren.class)
	public JAXBElement<String> createGetChildrenOrderBy(String value) {
		return new JAXBElement<String>(_GetChildrenOrderBy_QNAME, String.class,
				GetChildren.class, value);
	}
326124
@XmlElementDecl(namespace = "http://www.opengis.net/citygml/relief/2.0", name = "_GenericApplicationPropertyOfReliefComponent")
    public JAXBElement<Object> create_GenericApplicationPropertyOfReliefComponent(Object value) {
        return new JAXBElement<Object>(__GenericApplicationPropertyOfReliefComponent_QNAME, Object.class, null, value);
    }
1152163
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "onlyBasicPermissions", scope = GetACL.class)
	public JAXBElement<Boolean> createGetACLOnlyBasicPermissions(Boolean value) {
		return new JAXBElement<Boolean>(_GetACLOnlyBasicPermissions_QNAME,
				Boolean.class, GetACL.class, value);
	}
551172
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "filter", scope = GetProperties.class)
	public JAXBElement<String> createGetPropertiesFilter(String value) {
		return new JAXBElement<String>(_GetPropertiesFilter_QNAME,
				String.class, GetProperties.class, value);
	}
710170
@XmlElementDecl(namespace = "http://docs.oasis-open.org/ns/cmis/messaging/200908/", name = "includeAllowableActions", scope = GetChildren.class)
	public JAXBElement<Boolean> createGetChildrenIncludeAllowableActions(
			Boolean value) {
		return new JAXBElement<Boolean>(
				_GetObjectOfLatestVersionIncludeAllowableActions_QNAME,
				Boolean.class, GetChildren.class, value);
	}
538188
@XmlElementDecl(namespace = "http://openprovenance.org/model/opmPrinterConfig", name = "configuration")
    public JAXBElement<ProvPrinterConfiguration> createConfiguration(ProvPrinterConfiguration value) {
        return new JAXBElement<ProvPrinterConfiguration>(_Configuration_QNAME, ProvPrinterConfiguration.class, null, value);
    }
377114
public static String node2String(final Node node, boolean prettyPrint) throws UnsupportedEncodingException
   {
      return node2String(node, prettyPrint, Constants.DEFAULT_XML_CHARSET);
   }