Java源码示例:com.sun.xml.internal.xsom.XSSchemaSet
示例1
/**
* 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);
}
示例2
/**
* 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);
}
}
示例3
/**
* 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);
}
}
示例4
/**
* 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);
}
}
示例5
/**
* 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;
}
}
示例6
/**
* @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);
}
示例7
/**
* 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;
}
}
示例8
/**
* 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;
}
示例9
/**
* 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;
}
}
示例10
/**
* 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;
}
}
}
示例11
/**
* 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);
}
}
示例12
/**
* 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;
}
}
示例13
/**
* 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);
}
示例14
/**
* 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);
}
示例15
/**
* 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);
}
}
示例16
/**
* 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;
}
示例17
/**
* 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;
}
}
示例18
/**
* 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);
}
}
示例19
/**
* 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);
}
}
示例20
/**
* 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);
}
}
示例21
/**
* 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);
}
}
示例22
/**
* 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);
}
}
示例23
/**
* 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);
}
示例24
/**
* @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);
}
示例25
/**
* 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);
}
示例26
/**
* 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);
}
示例27
/**
* 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);
}
}
示例28
/**
* 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;
}
示例29
/**
* 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;
}
}
}
示例30
/**
* 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;
}