private static Schema readSchema()

in log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/util/XmlUtils.java [90:109]


    private static Schema readSchema() {

        // Read the schema file resource
        final String schemaFileName = "/log4j-changelog.xsd";
        final InputStream schemaInputStream = XmlUtils.class.getResourceAsStream(schemaFileName);
        if (schemaInputStream == null) {
            final String message = String.format("could not find the schema file resource: `%s`", schemaFileName);
            throw new RuntimeException(message);
        }

        // Read the schema
        try {
            final StreamSource schemaSource = new StreamSource(schemaInputStream);
            final SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            return schemaFactory.newSchema(schemaSource);
        } catch (final Exception error) {
            final String message = String.format("failed to load schema from file resource: `%s`", schemaFileName);
            throw new RuntimeException(message, error);
        }
    }