当前位置: 首页>>代码示例>>Java>>正文


Java SchemaOutputResolver.createOutput方法代码示例

本文整理汇总了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();
            }
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:56,代码来源:XmlSchemaGenerator.java

示例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();
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:58,代码来源:XmlSchemaGenerator.java


注:本文中的javax.xml.bind.SchemaOutputResolver.createOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。