com.sun.xml.internal.xsom.XSSchemaSet Java Examples

The following examples show how to use com.sun.xml.internal.xsom.XSSchemaSet. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BIGlobalBinding.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #2
Source File: SCDBasedBindingSet.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #3
Source File: BGMBuilder.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
Example #4
Source File: SCDBasedBindingSet.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #5
Source File: BIGlobalBinding.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #6
Source File: SCDBasedBindingSet.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #7
Source File: BIGlobalBinding.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs error check
 */
public void errorCheck() {
    ErrorReceiver er = Ring.get(ErrorReceiver.class);
    for (QName n : enumBaseTypes) {
        XSSchemaSet xs = Ring.get(XSSchemaSet.class);
        XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart());
        if(st==null) {
            er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n));
            continue;
        }

        if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) {
            er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n));
            continue;
        }
    }
}
 
Example #8
Source File: BIGlobalBinding.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #9
Source File: SCDBasedBindingSet.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #10
Source File: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #11
Source File: ModelLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #12
Source File: BGMBuilder.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
Example #13
Source File: ModelLoader.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #14
Source File: SCDBasedBindingSet.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #15
Source File: BGMBuilder.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
Example #16
Source File: ModelLoader.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #17
Source File: BIGlobalBinding.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #18
Source File: BIGlobalBinding.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #19
Source File: BGMBuilder.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Entry point.
 */
public static Model build( XSSchemaSet _schemas, JCodeModel codeModel,
        ErrorReceiver _errorReceiver, Options opts ) {
    // set up a ring
    final Ring old = Ring.begin();
    try {
        ErrorReceiverFilter ef = new ErrorReceiverFilter(_errorReceiver);

        Ring.add(XSSchemaSet.class,_schemas);
        Ring.add(codeModel);
        Model model = new Model(opts, codeModel, null/*set later*/, opts.classNameAllocator, _schemas);
        Ring.add(model);
        Ring.add(ErrorReceiver.class,ef);
        Ring.add(CodeModelClassFactory.class,new CodeModelClassFactory(ef));

        BGMBuilder builder = new BGMBuilder(opts.defaultPackage,opts.defaultPackage2,
            opts.isExtensionMode(),opts.getFieldRendererFactory(), opts.activePlugins);
        builder._build();

        if(ef.hadError())   return null;
        else                return model;
    } finally {
        Ring.end(old);
    }
}
 
Example #20
Source File: ModelLoader.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #21
Source File: Model.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}
 
Example #22
Source File: ModelLoader.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #23
Source File: ModelLoader.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a set of XML Schema files into an annotated grammar.
 */
public XSSchemaSet loadXMLSchema() throws SAXException {

    if( opt.strictCheck && !SchemaConstraintChecker.check(opt.getGrammars(),errorReceiver,opt.entityResolver, opt.disableXmlSecurity)) {
        // schema error. error should have been reported
        return null;
    }

    if(opt.getBindFiles().length==0) {
        // no external binding. try the speculative no DOMForest execution,
        // which is faster if the speculation succeeds.
        try {
            return createXSOMSpeculative();
        } catch( SpeculationFailure e) {
            // failed. go the slow way
        }
    }

    // the default slower way is to parse everything into DOM first.
    // so that we can take external annotations into account.
    DOMForest forest = buildDOMForest( new XMLSchemaInternalizationLogic() );
    return createXSOM(forest, scdBasedBindingSet);
}
 
Example #24
Source File: BIGlobalBinding.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Moves global BIConversion to the right object.
 */
public void dispatchGlobalConversions( XSSchemaSet schema ) {
    // also set parent to the global conversions
    for( Map.Entry<QName,BIConversion> e : globalConversions.entrySet() ) {

        QName name = e.getKey();
        BIConversion conv = e.getValue();

        XSSimpleType st = schema.getSimpleType(name.getNamespaceURI(),name.getLocalPart());
        if(st==null) {
            Ring.get(ErrorReceiver.class).error(
                getLocation(),
                Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(name)
            );
            continue; // abort
        }

        getBuilder().getOrCreateBindInfo(st).addDecl(conv);
    }
}
 
Example #25
Source File: ModelLoader.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #26
Source File: BIGlobalBinding.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs error check
 */
public void errorCheck() {
    ErrorReceiver er = Ring.get(ErrorReceiver.class);
    for (QName n : enumBaseTypes) {
        XSSchemaSet xs = Ring.get(XSSchemaSet.class);
        XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart());
        if(st==null) {
            er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n));
            continue;
        }

        if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) {
            er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n));
            continue;
        }
    }
}
 
Example #27
Source File: ModelLoader.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Parses a {@link DOMForest} into a {@link XSSchemaSet}.
 *
 * @return
 *      null if the parsing failed.
 */
public XSSchemaSet createXSOM(DOMForest forest, SCDBasedBindingSet scdBasedBindingSet) throws SAXException {
    // set up other parameters to XSOMParser
    XSOMParser reader = createXSOMParser(forest);

    // re-parse the transformed schemas
    for (String systemId : forest.getRootDocuments()) {
        errorReceiver.pollAbort();
        Document dom = forest.get(systemId);
        if (!dom.getDocumentElement().getNamespaceURI().equals(Const.JAXB_NSURI)) {
            reader.parse(systemId);
        }
    }

    XSSchemaSet result = reader.getResult();

    if(result!=null)
        scdBasedBindingSet.apply(result,errorReceiver);

    return result;
}
 
Example #28
Source File: BIGlobalBinding.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Performs error check
 */
public void errorCheck() {
    ErrorReceiver er = Ring.get(ErrorReceiver.class);
    for (QName n : enumBaseTypes) {
        XSSchemaSet xs = Ring.get(XSSchemaSet.class);
        XSSimpleType st = xs.getSimpleType(n.getNamespaceURI(), n.getLocalPart());
        if(st==null) {
            er.error(loc,Messages.ERR_UNDEFINED_SIMPLE_TYPE.format(n));
            continue;
        }

        if(!SimpleTypeBuilder.canBeMappedToTypeSafeEnum(st)) {
            er.error(loc,Messages.ERR_CANNOT_BE_BOUND_TO_SIMPLETYPE.format(n));
            continue;
        }
    }
}
 
Example #29
Source File: SCDBasedBindingSet.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
Example #30
Source File: Model.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param nc
 *      Usually this should be set in the constructor, but we do allow this parameter
 *      to be initially null, and then set later.
 * @param schemaComponent
 *      The source schema model, if this is built from XSD.
 */
public Model( Options opts, JCodeModel cm, NameConverter nc, ClassNameAllocator allocator, XSSchemaSet schemaComponent ) {
    this.options = opts;
    this.codeModel = cm;
    this.nameConverter = nc;
    this.defaultSymbolSpace = new SymbolSpace(codeModel);
    defaultSymbolSpace.setType(codeModel.ref(Object.class));

    elementMappings.put(null,new HashMap<QName,CElementInfo>());

    if(opts.automaticNameConflictResolution)
        allocator = new AutoClassNameAllocator(allocator);
    this.allocator = new ClassNameAllocatorWrapper(allocator);
    this.schemaComponent = schemaComponent;
    this.gloablCustomizations.setParent(this,this);
}