當前位置: 首頁>>代碼示例>>Java>>正文


Java SAXNotSupportedException類代碼示例

本文整理匯總了Java中org.xml.sax.SAXNotSupportedException的典型用法代碼示例。如果您正苦於以下問題:Java SAXNotSupportedException類的具體用法?Java SAXNotSupportedException怎麽用?Java SAXNotSupportedException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SAXNotSupportedException類屬於org.xml.sax包,在下文中一共展示了SAXNotSupportedException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureOldXerces

import org.xml.sax.SAXNotSupportedException; //導入依賴的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:liaokailin,項目名稱:tomcat7,代碼行數:26,代碼來源:XercesParser.java

示例2: configureOldXerces

import org.xml.sax.SAXNotSupportedException; //導入依賴的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:how2j,項目名稱:lazycat,代碼行數:25,代碼來源:XercesParser.java

示例3: newSAXParser

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
/**
 * Create a <code>SAXParser</code> based on the underlying
 * <code>Xerces</code> version.
 * @param properties parser specific properties/features
 * @return an XML Schema/DTD enabled <code>SAXParser</code>
 */
public static SAXParser newSAXParser(Properties properties) 
        throws ParserConfigurationException, 
               SAXException,
               SAXNotSupportedException {

    SAXParserFactory factory =  
                    (SAXParserFactory)properties.get("SAXParserFactory");

    if (versionNumber == null){
        versionNumber = getXercesVersion();
        version = Float.parseFloat(versionNumber);
    }

    // Note: 2.2 is completely broken (with XML Schema). 
    if (version > 2.1) {

        configureXerces(factory);
        return factory.newSAXParser();
    } else {
        SAXParser parser = factory.newSAXParser();
        configureOldXerces(parser,properties);
        return parser;
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:31,代碼來源:XercesParser.java

示例4: setProperty0

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
public void setProperty0(String propertyId, Object value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    try {
        fConfiguration.setProperty(propertyId, value);
    }
    catch (XMLConfigurationException e) {
        String identifier = e.getIdentifier();
        if (e.getType() == Status.NOT_RECOGNIZED) {
            throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-recognized", new Object [] {identifier}));
        }
        else {
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
                "property-not-supported", new Object [] {identifier}));
        }
    }

}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:DOMParser.java

示例5: getProperty

import org.xml.sax.SAXNotSupportedException; //導入依賴的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: evaluate

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
/**
 * The dyn:evaluate function evaluates a string as an XPath expression and returns
 * the resulting value, which might be a boolean, number, string, node set, result
 * tree fragment or external object. The sole argument is the string to be evaluated.
 * <p>
 * If the expression string passed as the second argument is an invalid XPath
 * expression (including an empty string), this function returns an empty node set.
 * <p>
 * You should only use this function if the expression must be constructed dynamically,
 * otherwise it is much more efficient to use the expression literally.
 *
 * @param myContext The ExpressionContext passed by the extension processor
 * @param xpathExpr The XPath expression string
 *
 * @return The evaluation result
 */
public static XObject evaluate(ExpressionContext myContext, String xpathExpr)
  throws SAXNotSupportedException
{
  if (myContext instanceof XPathContext.XPathExpressionContext)
  {
    XPathContext xctxt = null;
    try
    {
      xctxt = ((XPathContext.XPathExpressionContext) myContext).getXPathContext();
      XPath dynamicXPath = new XPath(xpathExpr, xctxt.getSAXLocator(),
                                     xctxt.getNamespaceContext(),
                                     XPath.SELECT);

      return dynamicXPath.execute(xctxt, myContext.getContextNode(),
                                  xctxt.getNamespaceContext());
    }
    catch (TransformerException e)
    {
      return new XNodeSet(xctxt.getDTMManager());
    }
  }
  else
    throw new SAXNotSupportedException(XSLMessages.createMessage(XSLTErrorResources.ER_INVALID_CONTEXT_PASSED, new Object[]{myContext })); //"Invalid context passed to evaluate "
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:ExsltDynamic.java

示例7: newSAXParserFactory

import org.xml.sax.SAXNotSupportedException; //導入依賴的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

示例8: setFeature

import org.xml.sax.SAXNotSupportedException; //導入依賴的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:SunburstApps,項目名稱:OpenJSharp,代碼行數:37,代碼來源:ParserAdapter.java

示例9: setFeature

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
public void setFeature(String name, boolean value)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        throw new NullPointerException();
    }
    try {
        fComponentManager.setFeature(name, value);
    }
    catch (XMLConfigurationException e) {
        final String identifier = e.getIdentifier();
        final String key;
        if (e.getType() == Status.NOT_ALLOWED) {
            //for now, the identifier can only be (XMLConstants.FEATURE_SECURE_PROCESSING)
            throw new SAXNotSupportedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                "jaxp-secureprocessing-feature", null));
        } else if (e.getType() == Status.NOT_RECOGNIZED) {
            key = "feature-not-recognized";
        } else {
            key = "feature-not-supported";
        }
        throw new SAXNotRecognizedException(
                SAXMessageFormatter.formatMessage(fComponentManager.getLocale(),
                key, new Object [] {identifier}));
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:27,代碼來源:ValidatorHandlerImpl.java

示例10: setFeature

import org.xml.sax.SAXNotSupportedException; //導入依賴的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: getFeature

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
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:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:ValidatorImpl.java

示例12: startElement

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
/**
 * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
 */
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    if (this.currentTag != null) {
        this.currentTag.startElement(uri, localName, qName, attributes);

    } else if (ROOTS.contains(localName)) {
        this.currentTag = new RootTag();
    } else if (IMPORT.equals(localName)) {
        // TODO SLT: There's something fishy with the parser, with the currentTag getting hosed if you import twice
        try {
            parser.parseDictionary(new URL(baseDir, attributes.getValue(0)));
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(e);
        }
    } else {
        throw new SAXNotSupportedException("bad tag:" + localName);
    }
}
 
開發者ID:salesforce,項目名稱:grammaticus,代碼行數:22,代碼來源:LanguageDictionaryHandler.java

示例13: setProperty

import org.xml.sax.SAXNotSupportedException; //導入依賴的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}));
    }
    fConfigurationChanged = true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ValidatorImpl.java

示例14: getProperty

import org.xml.sax.SAXNotSupportedException; //導入依賴的package包/類
public synchronized Object getProperty(String name)
    throws SAXNotRecognizedException, SAXNotSupportedException {
    if (name == null) {
        // TODO: Add localized error message.
        throw new NullPointerException();
    }
    if (fSAXParser != null && JAXP_SCHEMA_LANGUAGE.equals(name)) {
        // JAXP 1.2 support
        return fSAXParser.schemaLanguage;
    }

    /** Check to see if the property is managed by the security manager **/
    String propertyValue = (fSecurityManager != null) ?
            fSecurityManager.getLimitAsString(name) : null;
    if (propertyValue != null) {
        return propertyValue;
    } else {
        propertyValue = (fSecurityPropertyMgr != null) ?
            fSecurityPropertyMgr.getValue(name) : null;
        if (propertyValue != null) {
            return propertyValue;
        }
    }

    return super.getProperty(name);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:27,代碼來源:SAXParserImpl.java

示例15: getFactory

import org.xml.sax.SAXNotSupportedException; //導入依賴的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


注:本文中的org.xml.sax.SAXNotSupportedException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。