Examples of newValidator()


Examples of javax.xml.validation.Schema.newValidator()

    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setNamespaceAware( true );
    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    final Schema v2Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_2_0.xsd" ) ) );
    final Validator v2Validator = v2Schema.newValidator();
    final Schema v1Schema = SchemaFactory.newInstance( javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI )
        .newSchema( new StreamSource( getStreamFromClasspath( "persistence_1_0.xsd" ) ) );
    final Validator v1Validator = v1Schema.newValidator();

    InputSource source = new InputSource( is );
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
    docBuilder.setEntityResolver( resolver );
    List<SAXParseException> errors = new ArrayList<SAXParseException>();
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    private void parseXml(String xmlName) throws ParserConfigurationException, SAXException, IOException {
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        schemaFactory.setErrorHandler(new ErrorHandlerImpl());
        schemaFactory.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        Schema schema = schemaFactory.newSchema(SCHEMAS);
        Validator validator = schema.newValidator();
        validator.setFeature("http://apache.org/xml/features/validation/schema", true);
        validator.setResourceResolver(DEFAULT_RESOURCE_RESOLVER);
        validator.validate(new StreamSource(getXmlFile(xmlName)));
    }
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

   public static void validate(final Node node, final String schemaFile) throws Exception
   {
      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

      Schema schema = factory.newSchema(findResource(schemaFile));
      Validator validator = schema.newValidator();

      // validate the DOM tree
      try
      {
         validator.validate(new DOMSource(node));
View Full Code Here

Examples of javax.xml.validation.Schema.newValidator()

    final ByteArrayOutputStream bos = new ByteArrayOutputStream(512);
    generateSchema(bos);
    try {
      final SpringApplicationService springApplicationService = (SpringApplicationService) u.unmarshal(xml);
      final Schema schema = schemaFactory.newSchema(new StreamSource(new ByteArrayInputStream(bos.toByteArray())));
      final Validator validator = schema.newValidator();
      validator.validate(new JAXBSource(jc, springApplicationService));
      return springApplicationService;
    } catch (SAXException | IOException e) {
      throw new IllegalArgumentException("Failed to parse XML. The XML must conform to the following schema:\n" + bos, e);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.