Java Code Examples for com.sun.xml.internal.bind.v2.util.XmlFactory#createSchemaFactory()
The following examples show how to use
com.sun.xml.internal.bind.v2.util.XmlFactory#createSchemaFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaCache.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 2
Source File: DOMForest.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 3
Source File: SchemaCache.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 4
Source File: DOMForest.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 5
Source File: SchemaCache.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 6
Source File: DOMForest.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 7
Source File: SchemaCache.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 8
Source File: DOMForest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 9
Source File: DOMForest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 10
Source File: SchemaCache.java From hottub with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 11
Source File: DOMForest.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 12
Source File: SchemaCache.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 13
Source File: DOMForest.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 14
Source File: SchemaCache.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public ValidatorHandler newValidator() { synchronized(this) { if(schema==null) { try { // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); schema = allowExternalAccess(sf, "file", false).newSchema(source); } catch (SAXException e) { // we make sure that the schema is correct before we ship. throw new AssertionError(e); } } } ValidatorHandler handler = schema.newValidatorHandler(); return handler; }
Example 15
Source File: DOMForest.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Checks the correctness of the XML Schema documents and return true * if it's OK. * * <p> * This method performs a weaker version of the tests where error messages * are provided without line number information. So whenever possible * use {@link SchemaConstraintChecker}. * * @see SchemaConstraintChecker */ public boolean checkSchemaCorrectness(ErrorReceiver errorHandler) { try { boolean disableXmlSecurity = false; if (options != null) { disableXmlSecurity = options.disableXmlSecurity; } SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity); ErrorReceiverFilter filter = new ErrorReceiverFilter(errorHandler); sf.setErrorHandler(filter); Set<String> roots = getRootDocuments(); Source[] sources = new Source[roots.size()]; int i=0; for (String root : roots) { sources[i++] = new DOMSource(get(root),root); } sf.newSchema(sources); return !filter.hadError(); } catch (SAXException e) { // the errors should have been reported return false; } }
Example 16
Source File: SchemaCache.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public ValidatorHandler newValidator() { if (schema==null) { synchronized (this) { if (schema == null) { ResourceResolver resourceResolver = null; try (InputStream is = clazz.getResourceAsStream(resourceName)) { StreamSource source = new StreamSource(is); source.setSystemId(resourceName); // do not disable secure processing - these are well-known schemas SchemaFactory sf = XmlFactory.createSchemaFactory(XMLConstants.W3C_XML_SCHEMA_NS_URI, false); SchemaFactory schemaFactory = allowExternalAccess(sf, "file", false); if (createResolver) { resourceResolver = new ResourceResolver(clazz); schemaFactory.setResourceResolver(resourceResolver); } schema = schemaFactory.newSchema(source); } catch (IOException | SAXException e) { InternalError ie = new InternalError(e.getMessage()); ie.initCause(e); throw ie; } finally { if (resourceResolver != null) resourceResolver.closeStreams(); } } } } return schema.newValidatorHandler(); }