org.w3c.dom.TypeInfo#javax.xml.validation.ValidatorHandler源码实例Demo

下面列出了org.w3c.dom.TypeInfo#javax.xml.validation.ValidatorHandler 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TencentKona-8   文件: SchemaCache.java
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;
}
 
源代码2 项目: TencentKona-8   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码3 项目: freehealth-connector   文件: ValidatorHelper.java
protected static ValidatorHandler createValidatorForSchemaFiles(String... schemaFiles) throws TechnicalConnectorException {
   SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

   try {
      Source[] sources = new Source[0];

      for(int i = 0; i < schemaFiles.length; ++i) {
         String schemaFile = schemaFiles[i];
         InputStream in = SchemaValidatorHandler.class.getResourceAsStream(schemaFile);
         if (in == null) {
            throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_XML_INVALID, new Object[]{"Unable to find schemaFile " + schemaFile});
         }

         if (schemaFiles.length == 1) {
            sources = (Source[])((Source[])ArrayUtils.add(sources, new StreamSource(SchemaValidatorHandler.class.getResource(schemaFile).toExternalForm())));
         } else {
            Source source = new StreamSource(in);
            sources = (Source[])((Source[])ArrayUtils.add(sources, source));
         }
      }

      return schemaFactory.newSchema(sources).newValidatorHandler();
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码4 项目: freehealth-connector   文件: ValidatorHelper.java
protected static ValidatorHandler createValidatorForSchemaFiles(String... schemaFiles) throws TechnicalConnectorException {
   SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

   try {
      Source[] sources = new Source[0];

      for(int i = 0; i < schemaFiles.length; ++i) {
         String schemaFile = schemaFiles[i];
         InputStream in = SchemaValidatorHandler.class.getResourceAsStream(schemaFile);
         if (in == null) {
            throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_XML_INVALID, new Object[]{"Unable to find schemaFile " + schemaFile});
         }

         if (schemaFiles.length == 1) {
            sources = (Source[])((Source[])ArrayUtils.add(sources, new StreamSource(SchemaValidatorHandler.class.getResource(schemaFile).toExternalForm())));
         } else {
            Source source = new StreamSource(in);
            sources = (Source[])((Source[])ArrayUtils.add(sources, source));
         }
      }

      return schemaFactory.newSchema(sources).newValidatorHandler();
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码5 项目: freehealth-connector   文件: ValidatorHelper.java
protected static ValidatorHandler createValidatorForSchemaFiles(String... schemaFiles) throws TechnicalConnectorException {
   SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

   try {
      Source[] sources = new Source[0];

      for(int i = 0; i < schemaFiles.length; ++i) {
         String schemaFile = schemaFiles[i];
         InputStream in = SchemaValidatorHandler.class.getResourceAsStream(schemaFile);
         if (in == null) {
            throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.ERROR_XML_INVALID, new Object[]{"Unable to find schemaFile " + schemaFile});
         }

         if (schemaFiles.length == 1) {
            sources = (Source[])((Source[])ArrayUtils.add(sources, new StreamSource(SchemaValidatorHandler.class.getResource(schemaFile).toExternalForm())));
         } else {
            Source source = new StreamSource(in);
            sources = (Source[])((Source[])ArrayUtils.add(sources, source));
         }
      }

      return schemaFactory.newSchema(sources).newValidatorHandler();
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码6 项目: jdk8u60   文件: SchemaCache.java
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;
}
 
源代码7 项目: jdk8u60   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码8 项目: openjdk-jdk8u   文件: SchemaCache.java
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;
}
 
源代码9 项目: openjdk-jdk8u   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码10 项目: openjdk-jdk8u-backup   文件: SchemaCache.java
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;
}
 
源代码11 项目: openjdk-jdk8u-backup   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码12 项目: openjdk-jdk9   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码13 项目: iaf   文件: Json2Xml.java
public static String translate(JsonStructure json, URL schemaURL, boolean compactJsonArrays, String rootElement, boolean strictSyntax, boolean deepSearch, String targetNamespace, Map<String,Object> overrideValues) throws SAXException, IOException {
	ValidatorHandler validatorHandler = getValidatorHandler(schemaURL);
	List<XSModel> schemaInformation = getSchemaInformation(schemaURL);

	// create the validator, setup the chain
	Json2Xml j2x = new Json2Xml(validatorHandler,schemaInformation,compactJsonArrays,rootElement,strictSyntax);
	if (overrideValues!=null) {
		j2x.setOverrideValues(overrideValues);
	}
	if (targetNamespace!=null) {
		//if (DEBUG) System.out.println("setting targetNamespace ["+targetNamespace+"]");
		j2x.setTargetNamespace(targetNamespace);
	}
	j2x.setDeepSearch(deepSearch);

	return j2x.translate(json);
}
 
源代码14 项目: hottub   文件: SchemaCache.java
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;
}
 
private void parseAndValidate(InputStream input, Schema schema) throws XmlParseException, IOException {
    ValidatorHandler vHandler = schema.newValidatorHandler();
    vHandler.setContentHandler(this);
    vHandler.setErrorHandler(this);

    InputSource is = new InputSource(new InputStreamReader(input, "UTF-8"));
    is.setEncoding("UTF-8");

    try {
        XMLReader parser = XMLReaderFactory.createXMLReader();
        parser.setContentHandler(vHandler);
        parser.setErrorHandler(this);

        vHandler.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);

        parser.setFeature("http://apache.org/xml/features/validation/id-idref-checking", false);
        parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false);
        parser.setFeature("http://xml.org/sax/features/external-general-entities", false);
        parser.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

        parser.parse(is);
    } catch (SAXException e) {
        throw new XmlParseException(e.getMessage(), e);
    }
}
 
源代码16 项目: openjdk-8-source   文件: SchemaCache.java
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;
}
 
源代码17 项目: openjdk-8-source   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码18 项目: iaf   文件: AbstractXmlValidator.java
public String validate(Object input, IPipeLineSession session, String logPrefix, ValidatorHandler validatorHandler, XMLFilterImpl filter, ValidationContext context) throws XmlValidatorException, PipeRunException, ConfigurationException {

		if (filter != null) {
			// If a filter is present, connect its output to the context.contentHandler.
			// It is assumed that the filter input is already properly connected.
			filter.setContentHandler(context.getContentHandler());
			filter.setErrorHandler(context.getErrorHandler());
		} else {
			validatorHandler.setContentHandler(context.getContentHandler());
		}
		validatorHandler.setErrorHandler(context.getErrorHandler());

		InputSource is = getInputSource(Message.asMessage(input));

		return validate(is, validatorHandler, session, context);
	}
 
源代码19 项目: openjdk-8   文件: SCDBasedBindingSet.java
/**
 * Applies the additional binding customizations.
 */
public void apply(XSSchemaSet schema, ErrorReceiver errorReceiver) {
    if(topLevel!=null) {
        this.errorReceiver = errorReceiver;
        Unmarshaller u =  BindInfo.getCustomizationUnmarshaller();
        this.unmarshaller = u.getUnmarshallerHandler();
        ValidatorHandler v = BindInfo.bindingFileSchema.newValidator();
        v.setErrorHandler(errorReceiver);
        loader = new ForkContentHandler(v,unmarshaller);

        topLevel.applyAll(schema.getSchemas());

        this.loader = null;
        this.unmarshaller = null;
        this.errorReceiver = null;
    }
}
 
源代码20 项目: TencentKona-8   文件: ConfigReader.java
/**
 * Parses an xml config file and returns a Config object.
 *
 * @param xmlFile
 *        The xml config file which is passed by the user to annotation processing
 * @return
 *        A non null Config object
 */
private Config parseAndGetConfig (File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException {
    XMLReader reader;
    try {
        SAXParserFactory factory = XmlFactory.createParserFactory(disableSecureProcessing);
        reader = factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException e) {
        // in practice this will never happen
        throw new Error(e);
    }
    NGCCRuntimeEx runtime = new NGCCRuntimeEx(errorHandler);

    // set up validator
    ValidatorHandler validator = configSchema.newValidator();
    validator.setErrorHandler(errorHandler);

    // the validator will receive events first, then the parser.
    reader.setContentHandler(new ForkContentHandler(validator,runtime));

    reader.setErrorHandler(errorHandler);
    Config config = new Config(runtime);
    runtime.setRootHandler(config);
    reader.parse(new InputSource(xmlFile.toURL().toExternalForm()));
    runtime.reset();

    return config;
}
 
源代码21 项目: freehealth-connector   文件: ValidatorHelper.java
public static void validate(Source source, boolean xop, String... schemaLocations) throws TechnicalConnectorException {
   try {
      XOPValidationHandler handler = new XOPValidationHandler(xop);
      ValidatorHandler validator = createValidatorForSchemaFiles(schemaLocations);
      ErrorCollectorHandler collector = new ErrorCollectorHandler(handler);
      validator.setErrorHandler(collector);
      SAXParser parser = SAF.newSAXParser();
      parser.parse(convert(source), new ForkContentHandler(new ContentHandler[]{handler, validator}));
      handleValidationResult(collector);
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码22 项目: freehealth-connector   文件: ValidatorHelper.java
public static void validate(Source source, boolean xop, String... schemaLocations) throws TechnicalConnectorException {
   try {
      XOPValidationHandler handler = new XOPValidationHandler(xop);
      ValidatorHandler validator = createValidatorForSchemaFiles(schemaLocations);
      ErrorCollectorHandler collector = new ErrorCollectorHandler(handler);
      validator.setErrorHandler(collector);
      SAXParser parser = SAF.newSAXParser();
      parser.parse(convert(source), new ForkContentHandler(new ContentHandler[]{handler, validator}));
      handleValidationResult(collector);
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码23 项目: freehealth-connector   文件: ValidatorHelper.java
public static void validate(Source source, boolean xop, String... schemaLocations) throws TechnicalConnectorException {
   try {
      XOPValidationHandler handler = new XOPValidationHandler(xop);
      ValidatorHandler validator = createValidatorForSchemaFiles(schemaLocations);
      ErrorCollectorHandler collector = new ErrorCollectorHandler(handler);
      validator.setErrorHandler(collector);
      SAXParser parser = SAF.newSAXParser();
      parser.parse(convert(source), new ForkContentHandler(new ContentHandler[]{handler, validator}));
      handleValidationResult(collector);
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码24 项目: freehealth-connector   文件: ValidatorHelper.java
public static void validate(Source source, boolean xop, String... schemaLocations) throws TechnicalConnectorException {
   try {
      XOPValidationHandler handler = new XOPValidationHandler(xop);
      ValidatorHandler validator = createValidatorForSchemaFiles(schemaLocations);
      ErrorCollectorHandler collector = new ErrorCollectorHandler(handler);
      validator.setErrorHandler(collector);
      SAXParser parser = SAF.newSAXParser();
      parser.parse(convert(source), new ForkContentHandler(new ContentHandler[]{handler, validator}));
      handleValidationResult(collector);
   } catch (Exception var7) {
      throw handleException(var7);
   }
}
 
源代码25 项目: jdk8u60   文件: ConfigReader.java
/**
 * Parses an xml config file and returns a Config object.
 *
 * @param xmlFile
 *        The xml config file which is passed by the user to annotation processing
 * @return
 *        A non null Config object
 */
private Config parseAndGetConfig (File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException {
    XMLReader reader;
    try {
        SAXParserFactory factory = XmlFactory.createParserFactory(disableSecureProcessing);
        reader = factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException e) {
        // in practice this will never happen
        throw new Error(e);
    }
    NGCCRuntimeEx runtime = new NGCCRuntimeEx(errorHandler);

    // set up validator
    ValidatorHandler validator = configSchema.newValidator();
    validator.setErrorHandler(errorHandler);

    // the validator will receive events first, then the parser.
    reader.setContentHandler(new ForkContentHandler(validator,runtime));

    reader.setErrorHandler(errorHandler);
    Config config = new Config(runtime);
    runtime.setRootHandler(config);
    reader.parse(new InputSource(xmlFile.toURL().toExternalForm()));
    runtime.reset();

    return config;
}
 
源代码26 项目: openjdk-jdk8u   文件: ConfigReader.java
/**
 * Parses an xml config file and returns a Config object.
 *
 * @param xmlFile
 *        The xml config file which is passed by the user to annotation processing
 * @return
 *        A non null Config object
 */
private Config parseAndGetConfig (File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException {
    XMLReader reader;
    try {
        SAXParserFactory factory = XmlFactory.createParserFactory(disableSecureProcessing);
        reader = factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException e) {
        // in practice this will never happen
        throw new Error(e);
    }
    NGCCRuntimeEx runtime = new NGCCRuntimeEx(errorHandler);

    // set up validator
    ValidatorHandler validator = configSchema.newValidator();
    validator.setErrorHandler(errorHandler);

    // the validator will receive events first, then the parser.
    reader.setContentHandler(new ForkContentHandler(validator,runtime));

    reader.setErrorHandler(errorHandler);
    Config config = new Config(runtime);
    runtime.setRootHandler(config);
    reader.parse(new InputSource(xmlFile.toURL().toExternalForm()));
    runtime.reset();

    return config;
}
 
源代码27 项目: openjdk-jdk8u-backup   文件: ConfigReader.java
/**
 * Parses an xml config file and returns a Config object.
 *
 * @param xmlFile
 *        The xml config file which is passed by the user to annotation processing
 * @return
 *        A non null Config object
 */
private Config parseAndGetConfig (File xmlFile, ErrorHandler errorHandler, boolean disableSecureProcessing) throws SAXException, IOException {
    XMLReader reader;
    try {
        SAXParserFactory factory = XmlFactory.createParserFactory(disableSecureProcessing);
        reader = factory.newSAXParser().getXMLReader();
    } catch (ParserConfigurationException e) {
        // in practice this will never happen
        throw new Error(e);
    }
    NGCCRuntimeEx runtime = new NGCCRuntimeEx(errorHandler);

    // set up validator
    ValidatorHandler validator = configSchema.newValidator();
    validator.setErrorHandler(errorHandler);

    // the validator will receive events first, then the parser.
    reader.setContentHandler(new ForkContentHandler(validator,runtime));

    reader.setErrorHandler(errorHandler);
    Config config = new Config(runtime);
    runtime.setRootHandler(config);
    reader.parse(new InputSource(xmlFile.toURL().toExternalForm()));
    runtime.reset();

    return config;
}
 
源代码28 项目: iaf   文件: XmlValidator.java
protected PipeForward validate(String messageToValidate, IPipeLineSession session, boolean responseMode) throws XmlValidatorException, PipeRunException, ConfigurationException {
	ValidationContext context = validator.createValidationContext(session, getRootValidations(responseMode), getInvalidRootNamespaces());
	ValidatorHandler validatorHandler = validator.getValidatorHandler(session, context);
	XMLFilterImpl storeRootFilter = StringUtils.isNotEmpty(getRootElementSessionKey()) ? new RootElementToSessionKeyFilter(session, getRootElementSessionKey(), getRootNamespaceSessionKey(), null) : null;
	if (storeRootFilter!=null) {
		validatorHandler.setContentHandler(storeRootFilter);
	}
	String resultEvent = validator.validate(messageToValidate, session, getLogPrefix(session), validatorHandler, storeRootFilter, context);
	return determineForward(resultEvent, session, responseMode);
}
 
源代码29 项目: openjdk-jdk9   文件: SchemaCache.java
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();
}
 
源代码30 项目: iaf   文件: AbstractXmlValidator.java
public String validate(InputSource inputSource, ValidatorHandler validatorHandler, IPipeLineSession session, ValidationContext context) throws XmlValidatorException {
	try {
		XmlUtils.parseXml(inputSource, validatorHandler, context.getErrorHandler());
	} catch (IOException | SAXException e) {
		return finalizeValidation(context, session, e);
	}
	return finalizeValidation(context, session, null);
}