Java 8 SchemaFactory - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SchemaFactory class.

This code example shows how to use the following methods:newSchema, setFeature, SchemaFactory.newSchema
            assertTrue("Default value of feature on Validator should have been true.", value);
            value = validator.getFeature(FEATURE_STRING_DEFAULT_FALSE);
            assertFalse("Default value of feature on Validator should have been false.", value);
             
            // checking that the value propagates to the validator 
            factory.setFeature(FEATURE_STRING_DEFAULT_TRUE, false);
            factory.setFeature(FEATURE_STRING_DEFAULT_FALSE, true);
            schema = makeSchema(factory, sources);
            validator = schema.newValidator();
            value = validator.getFeature(FEATURE_STRING_DEFAULT_TRUE);
            assertFalse("Value of feature on Validator should have been false.", value);
            value = validator.getFeature(FEATURE_STRING_DEFAULT_FALSE);
            assertTrue("Value of feature on Validator should have been true.", value);
             
            // checking that the validator contains a copy of the features, not a reference 
            factory.setFeature(FEATURE_STRING_DEFAULT_TRUE, true);
            factory.setFeature(FEATURE_STRING_DEFAULT_FALSE, false);
            value = validator.getFeature(FEATURE_STRING_DEFAULT_TRUE);
            assertFalse("Value of feature on Validator should have stayed false.", value);
            value = validator.getFeature(FEATURE_STRING_DEFAULT_FALSE);

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
	public static void validate(Element xml) throws IOException, SAXException, 
			JDOMException { 
		// NOTE: Create a schema object without schema file name so that schemas 
		// will be obtained from whatever locations are provided in the document 
 
		Schema schema = factory.newSchema();
		ValidatorHandler vh = schema.newValidatorHandler();
		so = new SAXOutputter(vh);
		so.output(xml);
	} 
 
	// --------------------------------------------------------------------------- 
	// --- 
	// --- Variables 
	// --- 
	// --------------------------------------------------------------------------- 
 
	private static SchemaFactory factory = SchemaFactory
			.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
	private static SAXOutputter so;
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema, setErrorHandler
    } 
 
    @Override public ValidationResult validateSchema() { 
        ValidationHandler v = new ValidationHandler();
        SchemaFactory f = getFactory();
        f.setErrorHandler(v);
        try { 
            f.newSchema(getSchemaSources());
        } catch (SAXException e) {
            if (e instanceof SAXParseException) {
                v.error((SAXParseException) e);
            } else { 
                throw new XMLUnitException(e);
            } 
        } finally { 
            f.setErrorHandler(null);
        } 
        return v.getResult();
    } 
 
    @Override public ValidationResult validateInstance(Source s) {
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
 
    public static Schema getVersioningSchemaInfo() {
        Schema schema = null;
 
        try { 
            schema = SCHEMA_FACTORY.newSchema(
                    new StreamSource[]{
                            new StreamSource(VersioningFilter.class.getResourceAsStream("/META-INF/schema/xml/xml.xsd")),
                            new StreamSource(VersioningFilter.class.getResourceAsStream("/META-INF/schema/atom/atom.xsd")),
                            new StreamSource(VersioningFilter.class.getResourceAsStream("/META-INF/schema/versioning/versioning.xsd"))
                    }); 
        } catch(SAXException e) {
            LOG.error("Failed to create schema object!", e);
        } 
 
        return schema;
    } 
 
    public static String getXmlString(JAXBElement versioningInfo, Boolean formatXml, Schema schema) throws JAXBException {
        String packageName = versioningInfo.getValue().getClass().getPackage().getName();
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
		this.url = url;
	} 
 
	@Override 
	public Schema run() throws SAXException {
		return schemaFactory.newSchema( url );
	} 
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
 
        AssertArgument.isNotNullAndNotEmpty(xsdSources, "xsdSources");
        Source[] xsdSourcesArray = xsdSources.toArray(new Source[xsdSources.size()]);
        SchemaFactory schemaFactory = newSchemaFactory();
 
        this.schema = schemaFactory.newSchema(xsdSourcesArray);
    } 
 
    /** 
     * Set the validation error handler. 
     * @param errorHandler The validation error handler. 
     */ 
    public void setErrorHandler(ErrorHandler errorHandler) {
        this.errorHandler = errorHandler;
    } 
 
    /** 
     * Validate the supplied source against the namespaces referenced in it. 
     * @throws org.xml.sax.SAXException Validation error. 
     * @throws java.io.IOException Error reading the XSD Sources. 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
                    org.openrepose.filters.clientauth.basic.config.ObjectFactory.class, 
                    org.openrepose.filters.clientauth.openstack.config.ObjectFactory.class); 
 
            jaxbUnmarshaller = jaxbContext.createUnmarshaller();
 
            jaxbUnmarshaller.setSchema(SCHEMA_FACTORY.newSchema(
                    new StreamSource[]{
                        new StreamSource(SchemaTest.class.getResourceAsStream("/META-INF/schema/config/openstack-ids-auth/openstack-ids-auth.xsd")),
                        new StreamSource(SchemaTest.class.getResourceAsStream("/META-INF/schema/config/http-basic/http-basic.xsd")),
                        new StreamSource(SchemaTest.class.getResourceAsStream("/META-INF/schema/config/client-auth-n-configuration.xsd"))
                    })); 
        } 
 
        @Test
        public void shouldValidateAgainstStaticExample() throws Exception {
            final StreamSource sampleSource = new StreamSource(SchemaTest.class.getResourceAsStream("/META-INF/schema/examples/openstack/client-auth-n.cfg.xml"));
 
            assertNotNull("Expected element should not be null", jaxbUnmarshaller.unmarshal(sampleSource, ClientAuthConfig.class).getValue().getOpenstackAuth());
        } 
    } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setFeature
    public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
        return actual.getFeature(name);
    } 
 
    public void setFeature(String name, boolean value) throws SAXNotSupportedException, SAXNotRecognizedException {
        actual.setFeature(name, value);
    } 
 
    public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException {
        actual.setProperty(name, object);
    } 
 
    public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
        return actual.getProperty(name);
    } 
 
    public void setErrorHandler(ErrorHandler errorHandler) {
        actual.setErrorHandler(errorHandler);
    } 
 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
 
    public void setValidating(boolean validate) {
        if (validate) {
            this.schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            try { 
                this.schema = schemaFactory.newSchema(new StreamSource(getSchemaLocation()));
            } catch (org.xml.sax.SAXException e) {
                LOG.log(Level.SEVERE, "SCHEMA_FACTORY_EXCEPTION_MSG");
            } 
            try { 
                this.parserFactory.setSchema(this.schema);                
            } catch (UnsupportedOperationException e) {
                LOG.log(Level.WARNING, "DOC_PARSER_NOT_SUPPORTED", e);
            } 
        } 
    } 
 
 
    private DocumentBuilder getParser() {
        if (parser == null) {
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:newSchema
     
    public void setValidating(boolean validate) {
        if (validate) {
            this.schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            try { 
                this.schema = schemaFactory.newSchema(new StreamSource(getSchemaLocation()));
            } catch (org.xml.sax.SAXException e) {
                LOG.log(Level.SEVERE, "SCHEMA_FACTORY_EXCEPTION_MSG");
            } 
            try { 
                this.parserFactory.setSchema(this.schema);
            } catch (UnsupportedOperationException e) {
                LOG.log(Level.WARNING, "SAX_PARSER_NOT_SUPPORTED", e);
            } 
        } 
    } 
 
    public SAXParser getSAXParser() {
        return parser;
    } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 SchemaFactory Questions & Answers:

See Code Examples for Java 8 SchemaFactory Methods: