All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.chrl.nutils.xml.StringSchemaOutputResolver Maven / Gradle / Ivy

The newest version!
package at.chrl.nutils.xml;

import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
import java.io.IOException;
import java.io.StringWriter;

public class StringSchemaOutputResolver extends SchemaOutputResolver {

	private StringWriter sw = null;

	@Override
	public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
		sw = new StringWriter();
		StreamResult sr = new StreamResult();

		// If it's not set - schemagen throws AssertionError
		sr.setSystemId(String.valueOf(System.currentTimeMillis()));

		sr.setWriter(sw);
		return sr;
	}

	public String getSchemma() {
		return sw != null ? sw.toString() : null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy