Search in sources :

Example 66 with Source

use of javax.xml.transform.Source in project ORCID-Source by ORCID.

the class ValidateV2RC3Identifiers method validateSampleXML.

public void validateSampleXML(String name) throws SAXException, IOException {
    Source source = getInputStream("/record_2.0_rc3/samples/" + name + "-2.0_rc3.xml");
    Validator validator = getValidator(name);
    validator.validate(source);
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) JAXBSource(javax.xml.bind.util.JAXBSource) Validator(javax.xml.validation.Validator)

Example 67 with Source

use of javax.xml.transform.Source in project ORCID-Source by ORCID.

the class ValidateV2RC3Identifiers method getInputStream.

private Source getInputStream(String loc) {
    InputStream inputStream = MarshallingTest.class.getResourceAsStream(loc);
    Source source = new StreamSource(inputStream);
    return source;
}
Also used : InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) DOMSource(javax.xml.transform.dom.DOMSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) JAXBSource(javax.xml.bind.util.JAXBSource)

Example 68 with Source

use of javax.xml.transform.Source in project ORCID-Source by ORCID.

the class ValidateV2RC1SamplesTest method getInputStream.

private Source getInputStream(String loc) {
    InputStream inputStream = MarshallingTest.class.getResourceAsStream(loc);
    Source source = new StreamSource(inputStream);
    return source;
}
Also used : InputStream(java.io.InputStream) StreamSource(javax.xml.transform.stream.StreamSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) JAXBSource(javax.xml.bind.util.JAXBSource)

Example 69 with Source

use of javax.xml.transform.Source in project ORCID-Source by ORCID.

the class ValidateV2RC1SamplesTest method validateSampleXML.

public void validateSampleXML(String name) throws SAXException, IOException {
    Source source = getInputStream("/record_2.0_rc1/samples/" + name + "-2.0_rc1.xml");
    Validator validator = getValidator(name);
    validator.validate(source);
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) JAXBSource(javax.xml.bind.util.JAXBSource) Validator(javax.xml.validation.Validator)

Example 70 with Source

use of javax.xml.transform.Source in project ORCID-Source by ORCID.

the class ValidateOrcidMessage method validAgainstSchema.

private static boolean validAgainstSchema(File fileToValidate) {
    Validator validator = createValidator();
    Source source = new StreamSource(fileToValidate);
    try {
        validator.validate(source);
        System.out.println(fileToValidate + " is valid");
        return true;
    } catch (SAXException e) {
        System.out.println(fileToValidate + " is invalid");
        System.out.println(e);
    } catch (IOException e) {
        System.out.println("Unable to read file " + fileToValidate);
    }
    return false;
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) IOException(java.io.IOException) Validator(javax.xml.validation.Validator) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) SAXException(org.xml.sax.SAXException)

Aggregations

Source (javax.xml.transform.Source)238 StreamSource (javax.xml.transform.stream.StreamSource)161 DOMSource (javax.xml.transform.dom.DOMSource)108 Transformer (javax.xml.transform.Transformer)76 StreamResult (javax.xml.transform.stream.StreamResult)74 InputSource (org.xml.sax.InputSource)67 SAXSource (javax.xml.transform.sax.SAXSource)56 StringReader (java.io.StringReader)52 IOException (java.io.IOException)46 TransformerException (javax.xml.transform.TransformerException)45 Result (javax.xml.transform.Result)42 TransformerFactory (javax.xml.transform.TransformerFactory)41 Test (org.junit.Test)39 StringWriter (java.io.StringWriter)35 InputStream (java.io.InputStream)32 SAXException (org.xml.sax.SAXException)32 Schema (javax.xml.validation.Schema)29 Validator (javax.xml.validation.Validator)29 SchemaFactory (javax.xml.validation.SchemaFactory)28 ByteArrayInputStream (java.io.ByteArrayInputStream)26