Java XML JAXB Context generateTemporarySchemaFile(JAXBContext context)

Here you can find the source of generateTemporarySchemaFile(JAXBContext context)

Description

generate Temporary Schema File

License

Open Source License

Declaration

private static File generateTemporarySchemaFile(JAXBContext context)
            throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.IOException;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.SchemaOutputResolver;

import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;

public class Main {
    private static File generateTemporarySchemaFile(JAXBContext context)
            throws IOException {
        final File tempFile = File.createTempFile(
                "jaxb-junit-report-schema", ".xsd");
        context.generateSchema(new SchemaOutputResolver() {

            @Override/*w w  w.jav  a  2s. c  om*/
            public Result createOutput(String namespaceUri,
                    String suggestedFileName) throws IOException {
                StreamResult result = new StreamResult(tempFile);
                result.setSystemId(tempFile.toURI().toURL().toString());
                return result;
            }

        });
        return tempFile;
    }
}

Related

  1. clearContextCache()
  2. createContext(final Class bind)
  3. createJaxbContextFor(Object obj, Class[] classes)
  4. createRIContext(Class clss[], String defaultNS)
  5. fromXML(JAXBContext context, String requestXML)
  6. getCachedContext(String pkg)
  7. getContext()
  8. getContext()
  9. getContext()