Search in sources :

Example 6 with SchemaOutputResolver

use of javax.xml.bind.SchemaOutputResolver in project tomee by apache.

the class JAXBUtils method generateJaxbSchemas.

public static List<DOMResult> generateJaxbSchemas(JAXBContext context, final Map<String, DOMResult> builtIns) throws IOException {
    final List<DOMResult> results = new ArrayList<>();
    context.generateSchema(new SchemaOutputResolver() {

        @Override
        public Result createOutput(String ns, String file) throws IOException {
            DOMResult result = new DOMResult();
            if (builtIns.containsKey(ns)) {
                DOMResult dr = builtIns.get(ns);
                result.setSystemId(dr.getSystemId());
                results.add(dr);
                return result;
            }
            result.setSystemId(file);
            results.add(result);
            return result;
        }
    });
    return results;
}
Also used : SchemaOutputResolver(javax.xml.bind.SchemaOutputResolver) DOMResult(javax.xml.transform.dom.DOMResult) ArrayList(java.util.ArrayList) IOException(java.io.IOException) StreamResult(javax.xml.transform.stream.StreamResult) Result(javax.xml.transform.Result) DOMResult(javax.xml.transform.dom.DOMResult)

Example 7 with SchemaOutputResolver

use of javax.xml.bind.SchemaOutputResolver in project cxf by apache.

the class JAXBUtils method generateJaxbSchemas.

public static List<DOMResult> generateJaxbSchemas(JAXBContext context, final Map<String, DOMResult> builtIns) throws IOException {
    final List<DOMResult> results = new ArrayList<>();
    context.generateSchema(new SchemaOutputResolver() {

        @Override
        public Result createOutput(String ns, String file) throws IOException {
            DOMResult result = new DOMResult();
            if (builtIns.containsKey(ns)) {
                DOMResult dr = builtIns.get(ns);
                result.setSystemId(dr.getSystemId());
                results.add(dr);
                return result;
            }
            result.setSystemId(file);
            results.add(result);
            return result;
        }
    });
    return results;
}
Also used : SchemaOutputResolver(javax.xml.bind.SchemaOutputResolver) DOMResult(javax.xml.transform.dom.DOMResult) ArrayList(java.util.ArrayList) IOException(java.io.IOException) StreamResult(javax.xml.transform.stream.StreamResult) Result(javax.xml.transform.Result) DOMResult(javax.xml.transform.dom.DOMResult)

Example 8 with SchemaOutputResolver

use of javax.xml.bind.SchemaOutputResolver in project coprhd-controller by CoprHD.

the class SchemaApi method schema.

public static void schema() throws IOException {
    final StringWriter writer = new StringWriter();
    ApiModelPlugin.getInstance().getCtx().generateSchema(new SchemaOutputResolver() {

        public Result createOutput(String namespaceUri, String filename) throws IOException {
            Logger.debug("Generating API Schemas %s", filename);
            StreamResult result = new StreamResult(writer);
            result.setSystemId("schema.xsd");
            return result;
        }
    });
    renderXml(writer.toString());
}
Also used : SchemaOutputResolver(javax.xml.bind.SchemaOutputResolver) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) IOException(java.io.IOException) StreamResult(javax.xml.transform.stream.StreamResult) Result(javax.xml.transform.Result)

Aggregations

SchemaOutputResolver (javax.xml.bind.SchemaOutputResolver)8 IOException (java.io.IOException)6 Result (javax.xml.transform.Result)5 StreamResult (javax.xml.transform.stream.StreamResult)5 ArrayList (java.util.ArrayList)3 JAXBContext (javax.xml.bind.JAXBContext)3 StringWriter (java.io.StringWriter)2 JAXBException (javax.xml.bind.JAXBException)2 DOMResult (javax.xml.transform.dom.DOMResult)2 CharArrayWriter (java.io.CharArrayWriter)1 Constructor (java.lang.reflect.Constructor)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 PrivilegedActionException (java.security.PrivilegedActionException)1 HashSet (java.util.HashSet)1 GenericType (javax.ws.rs.core.GenericType)1 MediaType (javax.ws.rs.core.MediaType)1 JAXBIntrospector (javax.xml.bind.JAXBIntrospector)1 XmlRootElement (javax.xml.bind.annotation.XmlRootElement)1