本文整理了Java中org.apache.xerces.impl.xs.XMLSchemaLoader
类的一些代码示例,展示了XMLSchemaLoader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLSchemaLoader
类的具体详情如下:
包路径:org.apache.xerces.impl.xs.XMLSchemaLoader
类名称:XMLSchemaLoader
[英]This class implements xni.grammars.XMLGrammarLoader. It also serves as implementation of xs.XSLoader interface and DOMConfiguration interface. This class is designed to interact either with a proxy for a user application which wants to preparse schemas, or with our own Schema validator. It is hoped that none of these "external" classes will therefore need to communicate directly with XSDHandler in future.
This class only knows how to make XSDHandler do its thing. The caller must ensure that all its properties (schemaLocation, JAXPSchemaSource etc.) have been properly set.
[中]这个类实现了xni。语法。XMLGrammarLoader。它还充当xs的实现。XSLoader接口和DOMConfiguration接口。该类设计用于与希望准备模式的用户应用程序的代理交互,或与我们自己的模式验证器交互。希望这些“外部”类将来都不需要直接与XSDHandler通信。
这个类只知道如何让XSDHandler做自己的事情。调用者必须确保其所有属性(schemaLocation、JAXPSchemaSource等)都已正确设置。
代码示例来源:origin: elodina/xml-avro
public Schema createSchema(LSInput input) {
ErrorHandler errorHandler = new ErrorHandler();
XMLSchemaLoader loader = new XMLSchemaLoader();
if (resolver != null)
loader.setEntityResolver(new EntityResolver(resolver));
loader.setErrorHandler(errorHandler);
loader.setParameter(Constants.DOM_ERROR_HANDLER, errorHandler);
XSModel model = loader.load(input);
errorHandler.throwExceptionIfHasError();
return createSchema(model);
}
代码示例来源:origin: deegree/deegree3
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
schemaLoader.setFeature( SCHEMA_FULL_CHECKING_FEATURE_ID, true );
schemaLoader.setFeature( HONOUR_ALL_SCHEMA_LOCATIONS_ID, false );
schemaLoader.setEntityResolver( new RedirectingEntityResolver() );
schemaLoader.setErrorHandler( new XMLErrorHandler() {
@SuppressWarnings("synthetic-access")
@Override
schemaLoader.loadInputList( new LSInputListImpl( inputSchema, additionalSchemas ) );
return errors;
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
public XSModel load(LSInput is) {
try {
Grammar g = loadGrammar(dom2xmlInputSource(is));
return ((XSGrammar) g).toXSModel();
} catch (Exception e) {
reportDOMFatalError(e);
return null;
}
}
代码示例来源:origin: org.jboss.ws.native/jbossws-native-core
/**
* Get an instance of XSLoader that is capable of
* parsing schema files
* @param xeh XML Error handler
* @param xer XML Entity Resolver
* @return
*/
public XSLoader getXSLoader(XMLErrorHandler xeh, XMLEntityResolver xer)
{
XMLSchemaLoader xsloader = new XMLSchemaLoader();
xsloader.setEntityResolver(xer);
xsloader.setErrorHandler(xeh);
xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
return xsloader;
}
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
BaseSchemaFactory(String xsdVersion) {
fErrorHandlerWrapper = new ErrorHandlerWrapper(DraconianErrorHandler.getInstance());
fDOMEntityResolverWrapper = new DOMEntityResolverWrapper();
fXMLGrammarPoolWrapper = new XMLGrammarPoolWrapper();
fXMLSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, true);
fXMLSchemaLoader.setProperty(XMLGRAMMAR_POOL, fXMLGrammarPoolWrapper);
fXMLSchemaLoader.setProperty(XML_SCHEMA_VERSION, xsdVersion);
fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
fXSDVersion = xsdVersion;
fUseGrammarPoolOnly = true;
}
代码示例来源:origin: org.wso2.bpel/ode-utils
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
schemaLoader.setEntityResolver(cr);
schemaLoader.setFeature("http://apache.org/xml/features/honour-all-schemaLocations", true);
schemaLoader.setErrorHandler(eh);
XSModel model = schemaLoader.load(input);
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
SchemaGrammar parseXMLSchema(XMLInputSource is)
throws IOException {
XMLEntityResolver resolver = getEntityResolver();
if(resolver != null) {
fSchemaLoader.setEntityResolver(resolver);
}
if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, new XSMessageFormatter());
}
fSchemaLoader.setProperty(ERROR_REPORTER, fErrorReporter);
String propPrefix = Constants.XERCES_PROPERTY_PREFIX;
String propName = propPrefix + Constants.SCHEMA_LOCATION;
fSchemaLoader.setProperty(propName, getProperty(propName));
propName = propPrefix + Constants.SCHEMA_NONS_LOCATION;
fSchemaLoader.setProperty(propName, getProperty(propName));
propName = Constants.JAXP_PROPERTY_PREFIX+Constants.SCHEMA_SOURCE;
fSchemaLoader.setProperty(propName, getProperty(propName));
fSchemaLoader.setFeature(SCHEMA_FULL_CHECKING, getFeature(SCHEMA_FULL_CHECKING));
// Should check whether the grammar with this namespace is already in
// the grammar resolver. But since we don't know the target namespace
// of the document here, we leave such check to XSDHandler
SchemaGrammar grammar = (SchemaGrammar)fSchemaLoader.loadGrammar(is);
// by default, hand it off to the grammar pool
if (grammar != null) {
fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_SCHEMA,
new Grammar[]{grammar});
}
return grammar;
} // parseXMLSchema(XMLInputSource) : SchemaGrammar
代码示例来源:origin: org.wso2.bpel/ode-utils
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
InternalSchemaResolver resolver = new InternalSchemaResolver();
schemaLoader.setEntityResolver(resolver);
schemaLoader.setParameter(Constants.DOM_ERROR_HANDLER, new SchemaErrorHandler());
XSModel xsm = schemaLoader.loadInputList(list);
return new SchemaModelImpl(xsm);
代码示例来源:origin: org.jboss.ws.native/jbossws-native-core
/**
* Get an instance of XSLoader that is capable of
* parsing schema files
*
* @return
*/
public XSLoader getXSLoader()
{
XMLSchemaLoader xsloader = new XMLSchemaLoader();
JBossXSErrorHandler eh = new JBossXSErrorHandler();
xsloader.setErrorHandler(eh);
xsloader.setProperty("http://apache.org/xml/properties/internal/grammar-pool", new XMLGrammarPoolImpl());
return xsloader;
}
代码示例来源:origin: deegree/deegree3
IllegalAccessException {
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
DOMConfiguration config = schemaLoader.getConfig();
ErrorHandler errorHandler = new ErrorHandler();
schemaLoader.setEntityResolver( resolver );
XSModel model = schemaLoader.loadInputList( inputList );
if ( !errorHandler.getErrors().isEmpty() ) {
throw new XMLProcessingException( errorHandler.getErrors().get( 0 ) );
代码示例来源:origin: deegree/deegree3
IllegalAccessException {
XMLSchemaLoader schemaLoader = new XMLSchemaLoader();
DOMConfiguration config = schemaLoader.getConfig();
ErrorHandler errorHandler = new ErrorHandler();
schemaUrls[i] = resolver.redirect( schemaUrls[i] );
schemaLoader.setEntityResolver( resolver );
XSModel model = schemaLoader.loadURIList( new StringListImpl( schemaUrls, schemaUrls.length ) );
if ( !errorHandler.getErrors().isEmpty() ) {
throw new XMLProcessingException( errorHandler.getErrors().get( 0 ) );
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
public XSModel loadURI(String uri) {
try {
Grammar g = loadGrammar(new XMLInputSource(null, uri, null));
return ((XSGrammar)g).toXSModel();
}
catch (Exception e){
reportDOMFatalError(e);
return null;
}
}
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
/**
* Constructs a parser configuration using the specified symbol table,
* grammar pool, and parent settings.
* <p>
* <strong>REVISIT:</strong>
* Grammar pool will be updated when the new validation engine is
* implemented.
*
* @param symbolTable The symbol table to use.
* @param grammarPool The grammar pool to use.
* @param parentSettings The parent settings.
*/
public XMLGrammarCachingConfiguration(SymbolTable symbolTable,
XMLGrammarPool grammarPool,
XMLComponentManager parentSettings) {
super(symbolTable, grammarPool, parentSettings);
// REVISIT: may need to add some features/properties
// specific to this configuration at some point...
// add default recognized features
// set state for default features
// add default recognized properties
// create and register missing components
fSchemaLoader = new XMLSchemaLoader(fSymbolTable);
fSchemaLoader.setProperty(XMLGRAMMAR_POOL, fGrammarPool);
// and set up the DTD loader too:
fDTDLoader = new XMLDTDLoader(fSymbolTable, fGrammarPool);
} // <init>(SymbolTable,XMLGrammarPool, XMLComponentManager)
代码示例来源:origin: org.eclipse/org.eclipse.datatools.enablement.oda.xml
XSLoader xsLoader = new XMLSchemaLoader( );
LSInput input = new DOMInputImpl( );
try
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
return;
fXMLSchemaLoader.setFeature(name, value);
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
public void setResourceResolver(LSResourceResolver resourceResolver) {
fLSResourceResolver = resourceResolver;
fDOMEntityResolverWrapper.setEntityResolver(resourceResolver);
fXMLSchemaLoader.setEntityResolver(fDOMEntityResolverWrapper);
}
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
/**
* Returns a Grammar object by parsing the contents of the
* entities pointed to by sources.
*
* @param source the locations of the entity which forms
* the staring point of the grammars to be constructed
* @throws IOException when a problem is encounted reading the entity
* @throws XNIException when a condition arises (such as a FatalError) that requires parsing
* of the entity be terminated
*/
public void loadGrammar(XMLInputSource source[])
throws IOException, XNIException {
int numSource = source.length;
for (int i = 0; i < numSource; ++i) {
loadGrammar(source[i]);
}
}
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
public void setErrorHandler(ErrorHandler errorHandler) {
fErrorHandler = errorHandler;
fErrorHandlerWrapper.setErrorHandler(errorHandler != null ? errorHandler : DraconianErrorHandler.getInstance());
fXMLSchemaLoader.setErrorHandler(fErrorHandlerWrapper);
}
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
fSchemaLoader.setProperty(XML_SCHEMA_VERSION, value);
fSchemaVersion = fSchemaLoader.getSchemaVersion();
fXSConstraints = fSchemaLoader.getXSConstraints();
if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
if (fIDContext == null) {
代码示例来源:origin: com.rackspace.apache/xerces2-xsd11
/**
* No-args constructor.
*/
public XSLoaderImpl() {
fSchemaLoader.setProperty(XMLSchemaLoader.XMLGRAMMAR_POOL, fGrammarPool);
}
内容来源于网络,如有侵权,请联系作者删除!