• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XMLEntityResolver类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver的典型用法代码示例。如果您正苦于以下问题:Java XMLEntityResolver类的具体用法?Java XMLEntityResolver怎么用?Java XMLEntityResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XMLEntityResolver类属于com.sun.org.apache.xerces.internal.xni.parser包,在下文中一共展示了XMLEntityResolver类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getEntityResolver

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
/**
 * Return the current entity resolver.
 *
 * @return The current entity resolver, or null if none
 *         has been registered.
 * @see #setEntityResolver
 */
public EntityResolver getEntityResolver() {

    EntityResolver entityResolver = null;
    try {
        XMLEntityResolver xmlEntityResolver =
            (XMLEntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER);
        if (xmlEntityResolver != null) {
            if (xmlEntityResolver instanceof EntityResolverWrapper) {
                entityResolver =
                    ((EntityResolverWrapper) xmlEntityResolver).getEntityResolver();
            }
            else if (xmlEntityResolver instanceof EntityResolver2Wrapper) {
                entityResolver =
                    ((EntityResolver2Wrapper) xmlEntityResolver).getEntityResolver();
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }
    return entityResolver;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:AbstractSAXParser.java


示例2: parseDTD

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
DTDGrammar parseDTD(XMLInputSource is)
            throws IOException {
    XMLEntityResolver resolver = getEntityResolver();
    if(resolver != null) {
        fDTDLoader.setEntityResolver(resolver);
    }
    fDTDLoader.setProperty(ERROR_REPORTER, fErrorReporter);

    // 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 the application...
    DTDGrammar grammar = (DTDGrammar)fDTDLoader.loadGrammar(is);
    // by default, hand it off to the grammar pool
    if (grammar != null) {
        fGrammarPool.cacheGrammars(XMLGrammarDescription.XML_DTD,
                                  new Grammar[]{grammar});
    }

    return grammar;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:XMLGrammarCachingConfiguration.java


示例3: setEntityResolver

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
/**
 * Sets the resolver used to resolve external entities. The EntityResolver
 * interface supports resolution of public and system identifiers.
 *
 * @param resolver The new entity resolver. Passing a null value will
 *                 uninstall the currently installed resolver.
 */
public void setEntityResolver(EntityResolver resolver) {

    try {
        XMLEntityResolver xer = (XMLEntityResolver) fConfiguration.getProperty(ENTITY_RESOLVER);
        if (fUseEntityResolver2 && resolver instanceof EntityResolver2) {
            if (xer instanceof EntityResolver2Wrapper) {
                EntityResolver2Wrapper er2w = (EntityResolver2Wrapper) xer;
                er2w.setEntityResolver((EntityResolver2) resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolver2Wrapper((EntityResolver2) resolver));
            }
        }
        else {
            if (xer instanceof EntityResolverWrapper) {
                EntityResolverWrapper erw = (EntityResolverWrapper) xer;
                erw.setEntityResolver(resolver);
            }
            else {
                fConfiguration.setProperty(ENTITY_RESOLVER,
                        new EntityResolverWrapper(resolver));
            }
        }
    }
    catch (XMLConfigurationException e) {
        // do nothing
    }

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:38,代码来源:AbstractSAXParser.java


示例4: parseXMLSchema

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
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;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:XMLGrammarCachingConfiguration.java


示例5: reset

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
public void reset(XMLComponentManager componentManager) throws XMLConfigurationException {
    // obtain references from the manager
    fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
    fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
    try {
        fEntityResolver = (XMLEntityResolver) componentManager.getProperty(ENTITY_MANAGER);
    }
    catch (XMLConfigurationException e) {
        fEntityResolver = null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:JAXPValidatorComponent.java


示例6: setProperty

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
/**
 * Sets the value of a property. This method is called by the component
 * manager any time after reset when a property changes value.
 * <p>
 * <strong>Note:</strong> Components should silently ignore properties
 * that do not affect the operation of the component.
 *
 * @param propertyId The property identifier.
 * @param value      The value of the property.
 *
 * @throws SAXNotRecognizedException The component should not throw
 *                                   this exception.
 * @throws SAXNotSupportedException The component should not throw
 *                                  this exception.
 */
public void setProperty(String propertyId, Object value)
        throws XMLConfigurationException {
    if (propertyId.equals(SYMBOL_TABLE)) {
        fSymbolTable = (SymbolTable)value;
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if(propertyId.equals(ERROR_REPORTER)) {
        fErrorReporter = (XMLErrorReporter)value;
        // Add XML message formatter if there isn't one.
        if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
            XMLMessageFormatter xmft = new XMLMessageFormatter();
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
            fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
        }
        fDTDScanner.setProperty(propertyId, value);
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ERROR_HANDLER)) {
        fErrorReporter.setProperty(propertyId, value);
    }
    else if (propertyId.equals(ENTITY_RESOLVER)) {
        fEntityResolver = (XMLEntityResolver)value;
        fEntityManager.setProperty(propertyId, value);
    }
    else if (propertyId.equals(LOCALE)) {
        setLocale((Locale) value);
    }
    else if(propertyId.equals(GRAMMAR_POOL)) {
        fGrammarPool = (XMLGrammarPool)value;
    }
    else {
        throw new XMLConfigurationException(Status.NOT_RECOGNIZED, propertyId);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:51,代码来源:XMLDTDLoader.java


示例7: resolveDocument

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
/** This method tries to resolve location of the given schema.
 * The loader stores the namespace/location pairs in a hashtable (use "" as the
 * namespace of absent namespace). When resolving an entity, loader first tries
 * to find in the hashtable whether there is a value for that namespace,
 * if so, pass that location value to the user-defined entity resolver.
 *
 * @param desc
 * @param locationPairs
 * @param entityResolver
 * @return
 * @throws IOException
 */
public static XMLInputSource resolveDocument(XSDDescription desc, Map locationPairs,
        XMLEntityResolver entityResolver) throws IOException {
    String loc = null;
    // we consider the schema location properties for import
    if (desc.getContextType() == XSDDescription.CONTEXT_IMPORT ||
            desc.fromInstance()) {
        // use empty string as the key for absent namespace
        String namespace = desc.getTargetNamespace();
        String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
        // get the location hint for that namespace
        LocationArray tempLA = (LocationArray)locationPairs.get(ns);
        if(tempLA != null)
            loc = tempLA.getFirstLocation();
    }

    // if it's not import, or if the target namespace is not set
    // in the schema location properties, use location hint
    if (loc == null) {
        String[] hints = desc.getLocationHints();
        if (hints != null && hints.length > 0)
            loc = hints[0];
    }

    String expandedLoc = XMLEntityManager.expandSystemId(loc, desc.getBaseSystemId(), false);
    desc.setLiteralSystemId(loc);
    desc.setExpandedSystemId(expandedLoc);
    return entityResolver.resolveEntity(desc);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:XMLSchemaLoader.java


示例8: resolveDocument

import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; //导入依赖的package包/类
/**
 * This method tries to resolve location of the given schema.
 * The loader stores the namespace/location pairs in a map (use "" as the
 * namespace of absent namespace). When resolving an entity, loader first tries
 * to find in the map whether there is a value for that namespace,
 * if so, pass that location value to the user-defined entity resolver.
 *
 * @param desc
 * @param locationPairs
 * @param entityResolver
 * @return the XMLInputSource
 * @throws IOException
 */
public static XMLInputSource resolveDocument(XSDDescription desc,
        Map<String, LocationArray> locationPairs,
        XMLEntityResolver entityResolver) throws IOException {
    String loc = null;
    // we consider the schema location properties for import
    if (desc.getContextType() == XSDDescription.CONTEXT_IMPORT ||
            desc.fromInstance()) {
        // use empty string as the key for absent namespace
        String namespace = desc.getTargetNamespace();
        String ns = namespace == null ? XMLSymbols.EMPTY_STRING : namespace;
        // get the location hint for that namespace
        LocationArray tempLA = locationPairs.get(ns);
        if(tempLA != null)
            loc = tempLA.getFirstLocation();
    }

    // if it's not import, or if the target namespace is not set
    // in the schema location properties, use location hint
    if (loc == null) {
        String[] hints = desc.getLocationHints();
        if (hints != null && hints.length > 0)
            loc = hints[0];
    }

    String expandedLoc = XMLEntityManager.expandSystemId(loc, desc.getBaseSystemId(), false);
    desc.setLiteralSystemId(loc);
    desc.setExpandedSystemId(expandedLoc);
    return entityResolver.resolveEntity(desc);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:XMLSchemaLoader.java



注:本文中的com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EmptyPattern类代码示例发布时间:2022-05-23
下一篇:
Java Parseable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap