Search in sources :

Example 1 with Schema

use of org.iso_relax.verifier.Schema in project nokogiri by sparklemotion.

the class XmlRelaxng method createSchemaInstance.

static XmlSchema createSchemaInstance(ThreadContext context, RubyClass klazz, Source source) {
    Ruby runtime = context.getRuntime();
    XmlRelaxng xmlRelaxng = (XmlRelaxng) NokogiriService.XML_RELAXNG_ALLOCATOR.allocate(runtime, klazz);
    xmlRelaxng.setInstanceVariable("@errors", runtime.newEmptyArray());
    try {
        Schema schema = xmlRelaxng.getSchema(source, context);
        xmlRelaxng.setVerifier(schema.newVerifier());
        return xmlRelaxng;
    } catch (VerifierConfigurationException ex) {
        throw context.getRuntime().newRuntimeError("Could not parse document: " + ex.getMessage());
    }
}
Also used : Schema(org.iso_relax.verifier.Schema) Ruby(org.jruby.Ruby) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException)

Example 2 with Schema

use of org.iso_relax.verifier.Schema in project gocd by gocd.

the class XmlRelaxng method createSchemaInstance.

static XmlSchema createSchemaInstance(ThreadContext context, RubyClass klazz, Source source) {
    Ruby runtime = context.getRuntime();
    XmlRelaxng xmlRelaxng = (XmlRelaxng) NokogiriService.XML_RELAXNG_ALLOCATOR.allocate(runtime, klazz);
    xmlRelaxng.setInstanceVariable("@errors", runtime.newEmptyArray());
    try {
        Schema schema = xmlRelaxng.getSchema(source, context);
        xmlRelaxng.setVerifier(schema.newVerifier());
        return xmlRelaxng;
    } catch (VerifierConfigurationException ex) {
        throw context.getRuntime().newRuntimeError("Could not parse document: " + ex.getMessage());
    }
}
Also used : Schema(org.iso_relax.verifier.Schema) Ruby(org.jruby.Ruby) VerifierConfigurationException(org.iso_relax.verifier.VerifierConfigurationException)

Aggregations

Schema (org.iso_relax.verifier.Schema)2 VerifierConfigurationException (org.iso_relax.verifier.VerifierConfigurationException)2 Ruby (org.jruby.Ruby)2