本文整理了Java中org.apache.xerces.xs.XSImplementation.createXSLoader()
方法的一些代码示例,展示了XSImplementation.createXSLoader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XSImplementation.createXSLoader()
方法的具体详情如下:
包路径:org.apache.xerces.xs.XSImplementation
类名称:XSImplementation
方法名:createXSLoader
[英]Creates a new XSLoader. The newly constructed loader may then be configured and used to load XML Schemas.
[中]创建一个新的XSLoader。然后可以配置新构造的加载器,并将其用于加载XML模式。
代码示例来源:origin: jboss/jbossxb
public static XSModel loadSchema(String data, String encoding)
{
if(log.isTraceEnabled())
{
log.trace("loading xsd from string");
}
LSInputAdaptor input = new LSInputAdaptor(data, encoding);
XSImplementation impl = getXSImplementation();
XSLoader schemaLoader = impl.createXSLoader(null);
setDOMErrorHandler(schemaLoader);
return schemaLoader.load(input);
}
代码示例来源:origin: jboss/jbossxb
public static XSModel loadSchema(String xsdURL, SchemaBindingResolver schemaResolver)
{
boolean trace = log.isTraceEnabled();
long start = System.currentTimeMillis();
if(trace)
log.trace("loading xsd: " + xsdURL);
if(xsImpl == null)
{
xsImpl = getXSImplementation();
}
XSLoader schemaLoader = xsImpl.createXSLoader(null);
if(schemaResolver != null)
{
setResourceResolver(schemaLoader, schemaResolver);
}
setDOMErrorHandler(schemaLoader);
XSModel model = schemaLoader.loadURI(xsdURL);
if(model == null)
{
throw new IllegalArgumentException("Invalid URI for schema: " + xsdURL);
}
if (trace)
log.trace("Loaded xsd: " + xsdURL + " in " + (System.currentTimeMillis() - start) + "ms");
return model;
}
代码示例来源:origin: stackoverflow.com
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
XSImplementation impl = (XSImplementation) registry.getDOMImplementation("XS-Loader");
XSLoader schemaLoader = impl.createXSLoader(null);
XSModel xsModel = schemaLoader.loadURI(xsdResource.getURL().getPath());
((XSComplexTypeDecl) xsModel.getComponents(XSTypeDefinition.COMPLEX_TYPE).itemByName(xsdName, "typeName")).getAttrGrp().getAttributeUses();
代码示例来源:origin: dsukhoroslov/bagri
/**
* registers bunch of schemas located in the schemaUri folder
*
* @param modelUri String; the folder containing schemas to register
* @throws BagriException in case of any error
*/
@Override
public void registerModelUri(String modelUri) throws BagriException {
XSImplementation impl = new XSImplementationImpl();
XSLoader schemaLoader = impl.createXSLoader(null);
XSModel schema = schemaLoader.loadURI(modelUri);
processModel(schema);
}
代码示例来源:origin: jboss/jbossxb
public static XSModel loadSchema(Reader reader, String encoding, SchemaBindingResolver schemaResolver)
{
if(log.isTraceEnabled())
{
log.trace("loading xsd from Reader");
}
LSInputAdaptor input = new LSInputAdaptor(reader, encoding);
XSImplementation impl = getXSImplementation();
XSLoader schemaLoader = impl.createXSLoader(null);
setDOMErrorHandler(schemaLoader);
if(schemaResolver != null)
{
setResourceResolver(schemaLoader, schemaResolver);
}
return schemaLoader.load(input);
}
代码示例来源:origin: dsukhoroslov/bagri
/**
* registers bunch of schemas located in the schemaUri folder
*
* @param modelsUri String; the folder containing schemas to register
* @throws BagriException in case of any error
*/
//@Override
public void registerModels(String modelsUri) throws BagriException {
XSImplementation impl = (XSImplementation) new DOMXSImplementationSourceImpl().getDOMImplementation("XS-Loader LS");
XSLoader schemaLoader = impl.createXSLoader(null);
java.nio.file.Path catalog = Paths.get(modelsUri);
List<String> files = new ArrayList<>();
processCatalog(catalog, files);
if (files.size() > 0) {
StringList schemas = impl.createStringList(files.toArray(new String[files.size()]));
XSModel schema = schemaLoader.loadURIList(schemas);
processModel(schema);
}
}
代码示例来源:origin: jboss/jbossxb
public static XSModel loadSchema(InputStream is, String encoding, SchemaBindingResolver schemaResolver)
{
if(log.isTraceEnabled())
{
log.trace("loading xsd from InputStream");
}
LSInputAdaptor input = new LSInputAdaptor(is, encoding);
XSImplementation impl = getXSImplementation();
XSLoader schemaLoader = impl.createXSLoader(null);
setDOMErrorHandler(schemaLoader);
if(schemaResolver != null)
{
setResourceResolver(schemaLoader, schemaResolver);
}
return schemaLoader.load(input);
}
代码示例来源:origin: com.github.ansell.pellet/pellet-common
public XSNamedMap parseXMLSchema( URL url ) throws Exception {
if( log.isLoggable( Level.FINE ) )
log.fine( "Parsing XML Schema " + url );
// Use Xerces DOM Implementation
System.setProperty( DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl " );
// Get DOM Implementation Registry
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
// Get DOM Implementation using DOM Registry
DOMImplementationLS ls = (DOMImplementationLS) registry.getDOMImplementation( "LS" );
// create input
LSInput input = ls.createLSInput();
input.setCharacterStream( new InputStreamReader( url.openStream() ) );
// Get XS Implementation
XSImplementation impl = (XSImplementation) registry.getDOMImplementation( "XS-Loader" );
// Load XMLSchema
XSLoader schemaLoader = impl.createXSLoader( null );
XSModel schema = schemaLoader.load( input );
// Get simple type definitions
XSNamedMap map = schema.getComponents( XSTypeDefinition.SIMPLE_TYPE );
return map;
}
代码示例来源:origin: deegree/deegree3
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
XSImplementation impl = (XSImplementation) registry.getDOMImplementation( "XS-Loader" );
XSLoader schemaLoader = impl.createXSLoader( null );
代码示例来源:origin: eclipse/winery
XSLoader schemaLoader = impl.createXSLoader(null);
代码示例来源:origin: dsukhoroslov/bagri
/**
* registers bunch of node path's specified in the XML schema (XSD)
*
* @param model String; schema in plain text
* @throws BagriException in case of any error
*/
@Override
public void registerModel(String model) throws BagriException {
XSImplementation impl = (XSImplementation) new DOMXSImplementationSourceImpl().getDOMImplementation("XS-Loader LS");
XSLoader schemaLoader = impl.createXSLoader(null);
LSInput lsi = ((DOMImplementationLS) impl).createLSInput();
lsi.setStringData(model);
XSModel schema = schemaLoader.load(lsi);
processModel(schema);
}
代码示例来源:origin: AlexanderBartash/hybris-integration-intellij-idea-plugin
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
XSImplementation impl = (XSImplementation) registry.getDOMImplementation("XS-Loader");
XSLoader schemaLoader = impl.createXSLoader(null);
DOMConfiguration config = schemaLoader.getConfig();
代码示例来源:origin: org.apache.cxf/cxf-xerces-xsd-validation
void tryToParseSchemas(XmlSchemaCollection collection, DOMErrorHandler handler)
throws XmlSchemaSerializerException, TransformerException {
final List<DOMLSInput> inputs = new ArrayList<DOMLSInput>();
final Map<String, LSInput> resolverMap = new HashMap<String, LSInput>();
for (XmlSchema schema : collection.getXmlSchemas()) {
if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
continue;
}
Document document = new XmlSchemaSerializer().serializeSchema(schema, false)[0];
DOMLSInput input = new DOMLSInput(document, schema.getTargetNamespace());
resolverMap.put(schema.getTargetNamespace(), input);
inputs.add(input);
}
XSLoader schemaLoader = impl.createXSLoader(null);
schemaLoader.getConfig().setParameter("validate", Boolean.TRUE);
schemaLoader.getConfig().setParameter("error-handler", handler);
schemaLoader.getConfig().setParameter("resource-resolver", new LSResourceResolver() {
public LSInput resolveResource(String type, String namespaceURI, String publicId,
String systemId, String baseURI) {
return resolverMap.get(namespaceURI);
}
});
schemaLoader.loadInputList(new ListLSInput(inputs));
}
}
代码示例来源:origin: stackoverflow.com
XSLoader schemaLoader = impl.createXSLoader (null);
内容来源于网络,如有侵权,请联系作者删除!