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


Java SchemaFactory.setProperty方法代碼示例

本文整理匯總了Java中javax.xml.validation.SchemaFactory.setProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java SchemaFactory.setProperty方法的具體用法?Java SchemaFactory.setProperty怎麽用?Java SchemaFactory.setProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.validation.SchemaFactory的用法示例。


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

示例1: testValidation

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
public void testValidation(boolean setUseCatalog, boolean useCatalog, String catalog,
        String xsd, LSResourceResolver resolver)
        throws Exception {

    SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

    // use resolver or catalog if resolver = null
    if (resolver != null) {
        factory.setResourceResolver(resolver);
    }
    if (setUseCatalog) {
        factory.setFeature(XMLConstants.USE_CATALOG, useCatalog);
    }
    factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog);

    Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd)));
    success("XMLSchema.dtd and datatypes.dtd are resolved.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:19,代碼來源:CatalogSupportBase.java

示例2: allowExternalAccess

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing) {

        // if xml security (feature secure processing) disabled, nothing to do, no restrictions applied
        if (isXMLSecurityDisabled(disableSecureProcessing)) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Xml Security disabled, no JAXP xsd external access configuration necessary.");
            }
            return sf;
        }

        if (System.getProperty("javax.xml.accessExternalSchema") != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Detected explicitly JAXP configuration, no JAXP xsd external access configuration necessary.");
            }
            return sf;
        }

        try {
            sf.setProperty(ACCESS_EXTERNAL_SCHEMA, value);
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Property \"{0}\" is supported and has been successfully set by used JAXP implementation.", new Object[]{ACCESS_EXTERNAL_SCHEMA});
            }
        } catch (SAXException ignored) {
            // nothing to do; support depends on version JDK or SAX implementation
            if (LOGGER.isLoggable(Level.CONFIG)) {
                LOGGER.log(Level.CONFIG, "Property \"{0}\" is not supported by used JAXP implementation.", new Object[]{ACCESS_EXTERNAL_SCHEMA});
            }
        }
        return sf;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:XmlUtil.java

示例3: allowExternalAccess

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecureProcessing) {

        // if xml security (feature secure processing) disabled, nothing to do, no restrictions applied
        if (isXMLSecurityDisabled(disableSecureProcessing)) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_XML_SECURITY_DISABLED.format());
            }
            return sf;
        }

        if (System.getProperty("javax.xml.accessExternalSchema") != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_EXTERNAL_ACCESS_CONFIGURED.format());
            }
            return sf;
        }

        try {
            sf.setProperty(ACCESS_EXTERNAL_SCHEMA, value);
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_SUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA));
            }
        } catch (SAXException ignored) {
            // nothing to do; support depends on version JDK or SAX implementation
            if (LOGGER.isLoggable(Level.CONFIG)) {
                LOGGER.log(Level.CONFIG, Messages.JAXP_UNSUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_SCHEMA), ignored);
            }
        }
        return sf;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:XmlFactory.java

示例4: allowExternalDTDAccess

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
public static SchemaFactory allowExternalDTDAccess(SchemaFactory sf, String value, boolean disableSecureProcessing) {

        // if xml security (feature secure processing) disabled, nothing to do, no restrictions applied
        if (isXMLSecurityDisabled(disableSecureProcessing)) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_XML_SECURITY_DISABLED.format());
            }
            return sf;
        }

        if (System.getProperty("javax.xml.accessExternalDTD") != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_EXTERNAL_ACCESS_CONFIGURED.format());
            }
            return sf;
        }

        try {
            sf.setProperty(ACCESS_EXTERNAL_DTD, value);
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, Messages.JAXP_SUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_DTD));
            }
        } catch (SAXException ignored) {
            // nothing to do; support depends on version JDK or SAX implementation
            if (LOGGER.isLoggable(Level.CONFIG)) {
                LOGGER.log(Level.CONFIG, Messages.JAXP_UNSUPPORTED_PROPERTY.format(ACCESS_EXTERNAL_DTD), ignored);
            }
        }
        return sf;
    }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:XmlFactory.java

示例5: allowExternalAccess

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
public static SchemaFactory allowExternalAccess(SchemaFactory sf, String value, boolean disableSecurity) {

        // if xml security (feature secure processing) disabled, nothing to do, no restrictions applied
        if (xmlSecurityDisabled(disableSecurity)) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Xml Security disabled, no JAXP xsd external access configuration necessary.");
            }
            return sf;
        }

        if (System.getProperty("javax.xml.accessExternalSchema") != null) {
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Detected explicitly JAXP configuration, no JAXP xsd external access configuration necessary.");
            }
            return sf;
        }

        try {
            sf.setProperty(ACCESS_EXTERNAL_SCHEMA, value);
            if (LOGGER.isLoggable(Level.FINE)) {
                LOGGER.log(Level.FINE, "Property \"{0}\" is supported and has been successfully set by used JAXP implementation.", new Object[]{ACCESS_EXTERNAL_SCHEMA});
            }
        } catch (SAXException ignored) {
            // nothing to do; support depends on version JDK or SAX implementation
            if (LOGGER.isLoggable(Level.CONFIG)) {
                LOGGER.log(Level.CONFIG, "Property \"{0}\" is not supported by used JAXP implementation.", new Object[]{ACCESS_EXTERNAL_SCHEMA});
            }
        }
        return sf;
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:XmlUtil.java

示例6: testValidator

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
/**
 * Verifies Catalog Support for the Validator.
 * @param setUseCatalog1 a flag to indicate whether USE_CATALOG shall be set
 * on the factory.
 * @param setUseCatalog2 a flag to indicate whether USE_CATALOG shall be set
 * on the Validator.
 * @param source  the XML source
 * @param resolver1 a resolver to be set on the factory if specified
 * @param resolver2 a resolver to be set on the Validator if specified
 * @param catalog1 a catalog to be set on the factory if specified
 * @param catalog2 a catalog to be set on the Validator if specified
 */
public void testValidator(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog,
        Source source, LSResourceResolver resolver1, LSResourceResolver resolver2,
        String catalog1, String catalog2)
        throws Exception {

        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        if (setUseCatalog1) {
            schemaFactory.setFeature(XMLConstants.USE_CATALOG, useCatalog);
        }
        if (catalog1 != null) {
            schemaFactory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog1);
        }
        if (resolver1 != null) {
            schemaFactory.setResourceResolver(resolver1);
        }

        Schema schema = schemaFactory.newSchema();
        Validator validator = schema.newValidator();
        if (setUseCatalog2) {
            validator.setFeature(XMLConstants.USE_CATALOG, useCatalog);
        }
        if (catalog2 != null) {
            validator.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog2);
        }
        if (resolver2 != null) {
            validator.setResourceResolver(resolver2);
        }
        validator.validate(source);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:42,代碼來源:CatalogSupportBase.java

示例7: testSetUnrecognizedProperty

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
@Test(expectedExceptions = SAXNotRecognizedException.class)
public void testSetUnrecognizedProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
    SchemaFactory sf = newSchemaFactory();
    sf.setProperty(UNRECOGNIZED_NAME, "test");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:SchemaFactoryTest.java

示例8: testSetNullProperty

import javax.xml.validation.SchemaFactory; //導入方法依賴的package包/類
@Test(expectedExceptions = NullPointerException.class)
public void testSetNullProperty() throws SAXNotRecognizedException, SAXNotSupportedException {
    SchemaFactory sf = newSchemaFactory();
    assertNotNull(sf);
    sf.setProperty(null, "test");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:SchemaFactoryTest.java


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