/** * Load schema from the given resource. * * @param resource the resource to load from * @param schemaLanguage the language of the schema. Can be {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or * {@code XMLConstants.RELAXNG_NS_URI}. * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI * @see javax.xml.XMLConstants#RELAXNG_NS_URI */ public static Schema loadSchema(Resource resource, String schemaLanguage) throws IOException, SAXException { return loadSchema(new Resource[]{resource}, schemaLanguage); }
/** * Load schema from the given resource. * * @param resource the resource to load from * @param schemaLanguage the language of the schema. Can be {@code XMLConstants.W3C_XML_SCHEMA_NS_URI} or * {@code XMLConstants.RELAXNG_NS_URI}. * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI * @see javax.xml.XMLConstants#RELAXNG_NS_URI */ public static Schema loadSchema(Resource resource, String schemaLanguage) throws IOException, SAXException { return loadSchema(new Resource[]{resource}, schemaLanguage); }
/** * Load schema from the given resource. * * @param resource the resource to load from * @param schemaLanguage the language of the schema. Can be <code>XMLConstants.W3C_XML_SCHEMA_NS_URI</code> or * <code>XMLConstants.RELAXNG_NS_URI</code>. * @throws IOException if loading failed * @throws SAXException if loading failed * @see javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI * @see javax.xml.XMLConstants#RELAXNG_NS_URI */ public static Schema loadSchema(Resource resource, String schemaLanguage) throws IOException, SAXException { return loadSchema(new Resource[]{resource}, schemaLanguage); }
static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp15Validator(schema); } catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } }
static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp13Validator(schema); } catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } }
static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp13Validator(schema); } catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } }
static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp13Validator(schema); } catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } }
static XmlValidator createValidator(Resource[] resources, String schemaLanguage) throws IOException { try { Schema schema = SchemaLoaderUtils.loadSchema(resources, schemaLanguage); return new Jaxp15Validator(schema); } catch (SAXException ex) { throw new XmlValidationException("Could not create Schema: " + ex.getMessage(), ex); } }
@Override protected JAXBContext createJaxbContext() throws Exception { if (JaxbUtils.getJaxbVersion(classLoader) < JaxbUtils.JAXB_2) { throw new IllegalStateException( "Cannot use Jaxb2Marshaller in combination with JAXB 1.0. Use Jaxb1Marshaller instead."); } if (StringUtils.hasLength(getContextPath()) && !ObjectUtils.isEmpty(classesToBeBound)) { throw new IllegalArgumentException("specify either contextPath or classesToBeBound property; not both"); } if (!ObjectUtils.isEmpty(schemaResources)) { if (logger.isDebugEnabled()) { logger.debug( "Setting validation schema to " + StringUtils.arrayToCommaDelimitedString(schemaResources)); } schema = SchemaLoaderUtils.loadSchema(schemaResources, schemaLanguage); } if (StringUtils.hasLength(getContextPath())) { return createJaxbContextFromContextPath(); } else if (!ObjectUtils.isEmpty(classesToBeBound)) { return createJaxbContextFromClasses(); } else { throw new IllegalArgumentException("setting either contextPath or classesToBeBound is required"); } }