当前位置: 首页>>代码示例>>Java>>正文


Java SAXNotRecognizedException类代码示例

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


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

示例1: configureOldXerces

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
/**
 * Configure schema validation as recommended by the JAXP 1.2 spec.
 * The <code>properties</code> object may contains information about
 * the schema local and language. 
 * @param properties parser optional info
 */
private static void configureOldXerces(SAXParser parser, 
                                       Properties properties) 
        throws ParserConfigurationException, 
               SAXNotSupportedException {

    String schemaLocation = (String)properties.get("schemaLocation");
    String schemaLanguage = (String)properties.get("schemaLanguage");

    try{
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e){
        log.info(parser.getClass().getName() + ": " 
                                    + e.getMessage() + " not supported."); 
    }

}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:26,代码来源:XercesParser.java

示例2: setSchemaValidatorFeature

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
private void setSchemaValidatorFeature(String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    try {
        fSAXParser.fSchemaValidator.setFeature(name, value);
    }
    // This should never be thrown from the schema validator.
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "feature-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "feature-not-supported", new Object [] {identifier}));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:SAXParserImpl.java

示例3: newSAXParserFactory

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
public static SAXParserFactory newSAXParserFactory(boolean disableSecurity) {
    SAXParserFactory factory = SAXParserFactory.newInstance();
    String featureToSet = XMLConstants.FEATURE_SECURE_PROCESSING;
    try {
        boolean securityOn = !xmlSecurityDisabled(disableSecurity);
        factory.setFeature(featureToSet, securityOn);
        factory.setNamespaceAware(true);
        if (securityOn) {
            featureToSet = DISALLOW_DOCTYPE_DECL;
            factory.setFeature(featureToSet, true);
            featureToSet = EXTERNAL_GE;
            factory.setFeature(featureToSet, false);
            featureToSet = EXTERNAL_PE;
            factory.setFeature(featureToSet, false);
            featureToSet = LOAD_EXTERNAL_DTD;
            factory.setFeature(featureToSet, false);
        }
    } catch (ParserConfigurationException | SAXNotRecognizedException | SAXNotSupportedException e) {
        LOGGER.log(Level.WARNING, "Factory [{0}] doesn't support "+featureToSet+" feature!", new Object[]{factory.getClass().getName()});
    }
    return factory;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:XmlUtil.java

示例4: newSAXParser

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
/**
 * Create a <code>SAXParser</code> configured to support XML Scheman and DTD
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties)
        throws ParserConfigurationException, 
               SAXException,
               SAXNotRecognizedException{ 

    SAXParserFactory factory = 
                    (SAXParserFactory)properties.get("SAXParserFactory");
    SAXParser parser = factory.newSAXParser();
    String schemaLocation = (String)properties.get("schemaLocation");
    String schemaLanguage = (String)properties.get("schemaLanguage");

    try{
        if (schemaLocation != null) {
            parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
            parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
        }
    } catch (SAXNotRecognizedException e){
        log.info(parser.getClass().getName() + ": "  
                                    + e.getMessage() + " not supported."); 
    }
    return parser;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:GenericParser.java

示例5: getProperty

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
public Object getProperty(String name)
throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name.equals(Properties.LEXICAL_HANDLER_PROPERTY)) {
        return getLexicalHandler();
    } else if (name.equals(Properties.DTD_DECLARATION_HANDLER_PROPERTY)) {
        return getDeclHandler();
    } else if (name.equals(FastInfosetReader.EXTERNAL_VOCABULARIES_PROPERTY)) {
        return getExternalVocabularies();
    } else if (name.equals(FastInfosetReader.REGISTERED_ENCODING_ALGORITHMS_PROPERTY)) {
        return getRegisteredEncodingAlgorithms();
    } else if (name.equals(FastInfosetReader.ENCODING_ALGORITHM_CONTENT_HANDLER_PROPERTY)) {
        return getEncodingAlgorithmContentHandler();
    } else if (name.equals(FastInfosetReader.PRIMITIVE_TYPE_CONTENT_HANDLER_PROPERTY)) {
        return getPrimitiveTypeContentHandler();
    } else {
        throw new SAXNotRecognizedException(CommonResourceBundle.getInstance().
                getString("message.propertyNotRecognized", new Object[]{name}));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:SAXDocumentParser.java

示例6: getFactory

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
/**
 * Return the SAXParserFactory we will use, creating one if necessary.
 * 
 * @throws ParserConfigurationException
 * @throws SAXNotSupportedException
 * @throws SAXNotRecognizedException
 */
public SAXParserFactory getFactory()
		throws SAXNotRecognizedException, SAXNotSupportedException, ParserConfigurationException {

	if (factory == null) {
		factory = SAXParserFactory.newInstance();

		factory.setNamespaceAware(namespaceAware);
		// Preserve xmlns attributes
		if (namespaceAware) {
			factory.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
		}

		factory.setValidating(validating);
		if (validating) {
			// Enable DTD validation
			factory.setFeature("http://xml.org/sax/features/validation", true);
			// Enable schema validation
			factory.setFeature("http://apache.org/xml/features/validation/schema", true);
		}
	}
	return (factory);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:31,代码来源:Digester.java

示例7: setFeature

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
public void setFeature(String name, boolean value)
        throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name.equals(Features.NAMESPACES_FEATURE)) {
        if (!value) {
            throw new SAXNotSupportedException(name + ":" + value);
        }
    } else if (name.equals(Features.NAMESPACE_PREFIXES_FEATURE)) {
        _namespacePrefixesFeature = value;
    } else if (name.equals(Features.EXTERNAL_GENERAL_ENTITIES)) {
        // ignore
    } else if (name.equals(Features.EXTERNAL_PARAMETER_ENTITIES)) {
        // ignore
    } else if (name.equals(Features.STRING_INTERNING_FEATURE)) {
        if (value != _stringInterningFeature) {
            throw new SAXNotSupportedException(name + ":" + value);
        }
    } else {
        throw new SAXNotRecognizedException(
                "Feature not supported: " + name);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:SAXBufferProcessor.java

示例8: setFeature

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
/**
 * Set a feature flag for the parser.
 *
 * <p>The only features recognized are namespaces and
 * namespace-prefixes.</p>
 *
 * @param name The feature name, as a complete URI.
 * @param value The requested feature value.
 * @exception SAXNotRecognizedException If the feature
 *            can't be assigned or retrieved.
 * @exception SAXNotSupportedException If the feature
 *            can't be assigned that value.
 * @see org.xml.sax.XMLReader#setFeature
 */
public void setFeature (String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException
{
    if (name.equals(NAMESPACES)) {
        checkNotParsing("feature", name);
        namespaces = value;
        if (!namespaces && !prefixes) {
            prefixes = true;
        }
    } else if (name.equals(NAMESPACE_PREFIXES)) {
        checkNotParsing("feature", name);
        prefixes = value;
        if (!prefixes && !namespaces) {
            namespaces = true;
        }
    } else if (name.equals(XMLNS_URIs)) {
        checkNotParsing("feature", name);
        uris = value;
    } else {
        throw new SAXNotRecognizedException("Feature: " + name);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ParserAdapter.java

示例9: getFeature

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
@Override
public boolean getFeature(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        return fComponentManager.getFeature(name);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "feature-not-recognized" : "feature-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:ValidatorImpl.java

示例10: setFeature

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
private void setFeature(SAXParserFactory factory, String feature, boolean enable)
{
    try
    {
        if (ADDITIONAL_FEATURE_X_INCLUDE_AWARE.equals(feature))
        {
            factory.setXIncludeAware(enable);
        }
        else if (!ADDITIONAL_FEATURE_EXPAND_ENTITY_REFERENCES.equals(feature)) // Does not exist on SAXParserFactory
        {
            factory.setFeature(feature, enable);
        }
        debug(debugCounter+" SAXParserFactory "+feature+" "+enable);
    }
    catch (ParserConfigurationException | SAXNotSupportedException | SAXNotRecognizedException e)
    {
        logConfigurationFailure(factory.getClass().getName(), feature, e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-xml-factory,代码行数:20,代码来源:FactoryHelper.java

示例11: enableFileAccess

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
/**
 * Configure the parser to allow access to DTDs on the file system.
 */
private static void enableFileAccess(SAXParser parser) throws SAXNotSupportedException {
    try {
        parser.setProperty("http://javax.xml.XMLConstants/property/accessExternalDTD", "file");
    } catch (SAXNotRecognizedException ignore) {
        // property requires >= JAXP 1.5
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:CLDRConverter.java

示例12: getProperty

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
public Object getProperty(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    //Support current-element-node; return current node if DOMSource is used.
    if (CURRENT_ELEMENT_NODE.equals(name)) {
        return (fDOMValidatorHelper != null) ? fDOMValidatorHelper.getCurrentElement() : null;
    }
    try {
        return fComponentManager.getProperty(name);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "property-not-recognized" : "property-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:ValidatorImpl.java

示例13: setProperty

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
public void setProperty(String name, Object object)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        fComponentManager.setProperty(name, object);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key = e.getType() == Status.NOT_RECOGNIZED ?
                "property-not-recognized" : "property-not-supported";
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:ValidatorHandlerImpl.java

示例14: createParser

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
private static XmlParser createParser() {
    try {
        XmlParser parser = new XmlParser(false, true, true);
        try {
            // If not set for >= JAXP 1.5 / Java8 won't allow referencing DTDs, e.g.
            // using http URLs, because Groovy's XmlParser requests FEATURE_SECURE_PROCESSING
            parser.setProperty(ACCESS_EXTERNAL_DTD, ALLOW_ANY_EXTERNAL_DTD);
        } catch (SAXNotRecognizedException ignore) {
            // property requires >= JAXP 1.5 / Java8
        }
        return parser;
    } catch (Exception ex) {
        throw new UncheckedException(ex);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:DefaultDeploymentDescriptor.java

示例15: test1

import org.xml.sax.SAXNotRecognizedException; //导入依赖的package包/类
@Test
public void test1() throws SAXException {
    try {
        ValidatorHandler validatorHandler = schemaFactory.newSchema().newValidatorHandler();
        validatorHandler.getProperty("unknown1234");
        Assert.fail("SAXNotRecognizedException was not thrown.");
    } catch (SAXNotRecognizedException e) {
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Bug4969110.java


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