Search in sources :

Example 1 with NamespaceFilter

use of org.mule.runtime.module.extension.internal.capability.xml.schema.model.NamespaceFilter in project mule by mulesoft.

the class DefaultExtensionSchemaGenerator method renderSchema.

private String renderSchema(Schema schema) {
    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(Schema.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        NamespaceFilter outFilter = new NamespaceFilter(CORE_PREFIX, CORE_NAMESPACE, true);
        OutputFormat format = new OutputFormat();
        format.setIndent(true);
        format.setNewlines(true);
        StringWriter sw = new StringWriter();
        XMLWriter writer = new XMLWriter(sw, format);
        outFilter.setContentHandler(writer);
        marshaller.marshal(schema, outFilter);
        return sw.toString();
    } catch (JAXBException e) {
        throw new RuntimeException(e);
    }
}
Also used : Marshaller(javax.xml.bind.Marshaller) NamespaceFilter(org.mule.runtime.module.extension.internal.capability.xml.schema.model.NamespaceFilter) StringWriter(java.io.StringWriter) JAXBException(javax.xml.bind.JAXBException) OutputFormat(org.dom4j.io.OutputFormat) JAXBContext(javax.xml.bind.JAXBContext) XMLWriter(org.dom4j.io.XMLWriter)

Aggregations

StringWriter (java.io.StringWriter)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 OutputFormat (org.dom4j.io.OutputFormat)1 XMLWriter (org.dom4j.io.XMLWriter)1 NamespaceFilter (org.mule.runtime.module.extension.internal.capability.xml.schema.model.NamespaceFilter)1