Examples of XMLValidator


Examples of org.languagetool.XMLValidator

    final String result = check(german, "ein kleiner test. Und wieder Erwarten noch was: \u00f6\u00e4\u00fc\u00df.");
    assertTrue(result.contains("UPPERCASE_SENTENCE_START"));
    assertTrue(result.contains("WIEDER_WILLEN"));
    assertTrue("Expected special chars, got: '" + result + "'",
            result.contains("\u00f6\u00e4\u00fc\u00df"));   // special chars are intact
    final XMLValidator validator = new XMLValidator();
    validator.validateXMLString(result, JLanguageTool.getDataBroker().getResourceDir() + "/api-output.dtd", "matches");
    validator.checkSimpleXMLString(result);
    //System.err.println(result);
    // make sure XML chars are escaped in the result to avoid invalid XML
    // and XSS attacks:
    assertTrue(!check(german, "bla <script>").contains("<script>"));
View Full Code Here

Examples of org.openeai.xml.XmlValidator

    try {
      setSenderInfo("Query", producer);
      queryDoc = getQueryDoc();
      buildQueryMessage(queryDoc, keyObject);
      if (getValidation()) {
        XmlValidator xmlValidator = new XmlValidator();
        if (xmlValidator.isValid(queryDoc) == false) {
          outputXMLDocument(queryDoc, "Contents of Query document.");
          throw new EnterpriseObjectQueryException(getElementName() +
            " - Query document is not valid!");
        }
      }
View Full Code Here

Examples of org.openeai.xml.XmlValidator

    try {
      setSenderInfo("Generate", producer);
      genDoc = getGenerateDoc();
      buildGenerateMessage(genDoc, keyObject);
      if (getValidation()) {
        XmlValidator xmlValidator = new XmlValidator();
        if (xmlValidator.isValid(genDoc) == false) {
          outputXMLDocument(genDoc, "Contents of Generate document.");
          throw new EnterpriseObjectGenerateException("Generate document is not valid for " + getClass().getName());
        }
      }

      /*
      TextMessage responseMessage = (TextMessage)produceRequest(producer, genDoc);
      String responseText = responseMessage.getText();
      if (responseText == null) {
        throw new EnterpriseObjectGenerateException("A null response was returned from the server -  " + getElementName());
      }
      */

      // Get the results out of the TextMessage
      Document responseDoc = null;
//      try {
//        SAXBuilder builder = new SAXBuilder(false);
//        responseDoc = builder.build(new ByteArrayInputStream(responseText.getBytes()));
        responseDoc = producer.produceRequest(this, genDoc);
        if (getValidation()) {
          XmlValidator xmlValidator = new XmlValidator();
          if (xmlValidator.isValid(responseDoc) == false) {
            throw new EnterpriseObjectGenerateException("Generate response document is not valid for " + getClass().getName());
          }
        }

        Element controlArea = getControlArea(responseDoc.getRootElement());
View Full Code Here

Examples of org.openeai.xml.XmlValidator

    Result aResult = null;

    try {
      if (getValidation()) {
        XmlValidator xmlValidator = new XmlValidator();
        if (xmlValidator.isValid(doc) == false) {
          logger.fatal(title + " document is not valid.");
          outputXMLDocument(doc, "Contents of " + title + " document.");
          throw new EnterpriseObjectException(title + " document is not valid!");
        }
      }
View Full Code Here

Examples of org.openeai.xml.XmlValidator

    // was when this method was called...
    saveLayoutManagers();

    try {
      if (getValidation()) {
        XmlValidator xmlValidator = new XmlValidator();
        if (xmlValidator.isValid(syncDoc) == false) {
          throw new EnterpriseObjectSyncException(title + " document is not valid!");
        }
      }
      producer.publishMessage(this, syncDoc);
    }
View Full Code Here

Examples of org.springframework.xml.validation.XmlValidator

        Resource a = new ClassPathResource("A.xsd", AbstractXsdSchemaTestCase.class);
        collection.setXsds(new Resource[]{a});
        collection.setInline(true);
        collection.afterPropertiesSet();

        XmlValidator validator = collection.createValidator();
        Assert.assertNotNull("No XmlValidator returned", validator);
    }
View Full Code Here

Examples of org.springframework.xml.validation.XmlValidator

    protected abstract SoapMessage createSoapMessage() throws Exception;

    @Test
    public void testValidate() throws Exception {
        XmlValidator validator =
                XmlValidatorFactory.createValidator(getSoapSchemas(), XmlValidatorFactory.SCHEMA_W3C_XML);
        SAXParseException[] errors = validator.validate(soapMessage.getEnvelope().getSource());
        if (errors.length > 0) {
            fail(StringUtils.arrayToCommaDelimitedString(errors));
        }
    }
View Full Code Here

Examples of org.springframework.xml.validation.XmlValidator

    @Test
    public void testCreateValidator() throws Exception {
        Resource resource = new ClassPathResource("single.xsd", AbstractXsdSchemaTestCase.class);
        XsdSchema single = createSchema(resource);
        XmlValidator validator = single.createValidator();
        Assert.assertNotNull("No XmlValidator returned", validator);
    }
View Full Code Here

Examples of org.springframework.xml.validation.XmlValidator

                return;
            }

            log.info("Starting XML schema validation ...");

            XmlValidator validator = null;
            XsdSchemaRepository schemaRepository = null;
            if (validationContext.getSchema() != null) {
                validator = applicationContext.getBean(validationContext.getSchema(), XsdSchema.class).createValidator();
            } else if (validationContext.getSchemaRepository() != null) {
                schemaRepository = applicationContext.getBean(validationContext.getSchemaRepository(), XsdSchemaRepository.class);
            } else if (schemaRepositories.size() == 1) {
                schemaRepository = schemaRepositories.get(0);
            } else if (schemaRepositories.size() > 0) {
                for (XsdSchemaRepository repository : schemaRepositories) {
                    if (repository.canValidate(doc)) {
                        schemaRepository = repository;
                    }
                }
               
                if (schemaRepository == null) {
                    throw new CitrusRuntimeException(String.format("Failed to find proper schema repository in Spring bean context for validating element '%s(%s)'",
                            doc.getFirstChild().getLocalName(), doc.getFirstChild().getNamespaceURI()));
                }
            } else {
                log.warn("Neither schema instance nor schema repository defined - skipping XML schema validation");
                return;
            }
           
            if (schemaRepository != null) {
                if (!schemaRepository.canValidate(doc)) {
                    throw new CitrusRuntimeException(String.format("Unable to find proper XML schema definition for element '%s(%s)' in schema repository '%s'",
                            doc.getFirstChild().getLocalName(),
                            doc.getFirstChild().getNamespaceURI(),
                            schemaRepository.getName()));
                }

                List<Resource> schemas = new ArrayList<Resource>();

                for (XsdSchema xsdSchema : schemaRepository.getSchemas()) {
                    if (xsdSchema instanceof MultiResourceXsdSchema) {
                        for (Resource resource : ((MultiResourceXsdSchema) xsdSchema).getSchemas()) {
                            schemas.add(resource);
                        }                           
                    } else if (xsdSchema instanceof WsdlXsdSchema) {
                        for (Resource resource : ((WsdlXsdSchema) xsdSchema).getSchemas()) {
                            schemas.add(resource);
                        }
                    } else {
                        synchronized (transformerFactory) {
                            ByteArrayOutputStream bos = new ByteArrayOutputStream();
                            try {
                                transformerFactory.newTransformer().transform(xsdSchema.getSource(), new StreamResult(bos));
                            } catch (TransformerException e) {
                                throw new CitrusRuntimeException("Failed to read schema " + xsdSchema.getTargetNamespace(), e);
                            }
                            schemas.add(new ByteArrayResource(bos.toByteArray()));
                        }
                    }
                }
               
                validator = XmlValidatorFactory.createValidator(schemas.toArray(new Resource[schemas.size()]), WsdlXsdSchema.W3C_XML_SCHEMA_NS_URI);
            }
           
            SAXParseException[] results = validator.validate(new DOMSource(doc));
            if (results.length == 0) {
                log.info("Schema of received XML validated OK");
            } else {
                log.error("Schema validation failed for message:\n" +
                        XMLUtils.prettyPrint(receivedMessage.getPayload().toString()));
View Full Code Here

Examples of xdoclet.util.XmlValidator

            log.debug("getSchema()=" + getSchema());
            log.debug("getSchemaURL()=" + getSchemaURL());
        }

        if (shouldValidate()) {
            XmlValidator validator = XmlValidator.getInstance();

            validator.reset();

            if (getPublicId() != null) {
                validator.registerDTD(getPublicId(), getDtdURL());
            }
            if (getSchemaURL() != null) {
                validator.registerSchema(getSchemaURL());
            }
        }

        // reset ids counter
        IdTagsHandler.reset();
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.