本文整理汇总了Java中javax.xml.bind.SchemaOutputResolver.createOutput方法的典型用法代码示例。如果您正苦于以下问题:Java SchemaOutputResolver.createOutput方法的具体用法?Java SchemaOutputResolver.createOutput怎么用?Java SchemaOutputResolver.createOutput使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.bind.SchemaOutputResolver
的用法示例。
在下文中一共展示了SchemaOutputResolver.createOutput方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import javax.xml.bind.SchemaOutputResolver; //导入方法依赖的package包/类
/**
* Write out the schema documents.
*/
public void write(SchemaOutputResolver resolver, ErrorListener errorListener) throws IOException {
if(resolver==null)
throw new IllegalArgumentException();
if(logger.isLoggable(Level.FINE)) {
// debug logging to see what's going on.
logger.log(Level.FINE,"Wrigin XML Schema for "+toString(),new StackRecorder());
}
// make it fool-proof
resolver = new FoolProofResolver(resolver);
this.errorListener = errorListener;
Map<String, String> schemaLocations = types.getSchemaLocations();
Map<Namespace,Result> out = new HashMap<Namespace,Result>();
Map<Namespace,String> systemIds = new HashMap<Namespace,String>();
// we create a Namespace object for the XML Schema namespace
// as a side-effect, but we don't want to generate it.
namespaces.remove(WellKnownNamespace.XML_SCHEMA);
// first create the outputs for all so that we can resolve references among
// schema files when we write
for( Namespace n : namespaces.values() ) {
String schemaLocation = schemaLocations.get(n.uri);
if(schemaLocation!=null) {
systemIds.put(n,schemaLocation);
} else {
Result output = resolver.createOutput(n.uri,"schema"+(out.size()+1)+".xsd");
if(output!=null) { // null result means no schema for that namespace
out.put(n,output);
systemIds.put(n,output.getSystemId());
}
}
}
// then write'em all
for( Map.Entry<Namespace,Result> e : out.entrySet() ) {
Result result = e.getValue();
e.getKey().writeTo( result, systemIds );
if(result instanceof StreamResult) {
OutputStream outputStream = ((StreamResult)result).getOutputStream();
if(outputStream != null) {
outputStream.close(); // fix for bugid: 6291301
} else {
final Writer writer = ((StreamResult)result).getWriter();
if(writer != null) writer.close();
}
}
}
}
示例2: write
import javax.xml.bind.SchemaOutputResolver; //导入方法依赖的package包/类
/**
* Write out the schema documents.
*/
public void write(SchemaOutputResolver resolver, ErrorListener errorListener) throws IOException {
if(resolver==null)
throw new IllegalArgumentException();
if(logger.isLoggable(Level.FINE)) {
// debug logging to see what's going on.
logger.log(Level.FINE,"Writing XML Schema for "+toString(),new StackRecorder());
}
// make it fool-proof
resolver = new FoolProofResolver(resolver);
this.errorListener = errorListener;
Map<String, String> schemaLocations = types.getSchemaLocations();
Map<Namespace,Result> out = new HashMap<Namespace,Result>();
Map<Namespace,String> systemIds = new HashMap<Namespace,String>();
// we create a Namespace object for the XML Schema namespace
// as a side-effect, but we don't want to generate it.
namespaces.remove(WellKnownNamespace.XML_SCHEMA);
// first create the outputs for all so that we can resolve references among
// schema files when we write
for( Namespace n : namespaces.values() ) {
String schemaLocation = schemaLocations.get(n.uri);
if(schemaLocation!=null) {
systemIds.put(n,schemaLocation);
} else {
Result output = resolver.createOutput(n.uri,"schema"+(out.size()+1)+".xsd");
if(output!=null) { // null result means no schema for that namespace
out.put(n,output);
systemIds.put(n,output.getSystemId());
}
}
//Clear the namespace specific set with already written classes
n.resetWritten();
}
// then write'em all
for( Map.Entry<Namespace,Result> e : out.entrySet() ) {
Result result = e.getValue();
e.getKey().writeTo( result, systemIds );
if(result instanceof StreamResult) {
OutputStream outputStream = ((StreamResult)result).getOutputStream();
if(outputStream != null) {
outputStream.close(); // fix for bugid: 6291301
} else {
final Writer writer = ((StreamResult)result).getWriter();
if(writer != null) writer.close();
}
}
}
}