Is there any best way to validate generated XML against XSD in Java
<p>I'm generating the xml using Javax Marshaller. I'm looking for the way to validate the generated XML agaisnt XSD. I found gradle plugin to do this. But I couldnt use this plugin,because it is giving some error</p>

<pre><code>Could not resolve gradle.plugin.com.github.ramonwirsch:fopRenderer:0.1.7
</code></pre>

<p>My build.gradle file:</p>

<pre><code>buildscript {
  repositories {
      jcenter()  
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.com.github.ramonwirsch:fopRenderer:0.1.7"
  }
}

apply plugin: "com.github.ramonwirsch.FopRenderer"
apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility=1.8
targetCompatibility=1.8

project.ext {
    app_name='XSD-XML'
    build_date=new Date().format("yyyyMMddHHmm")
    release_number='R1.0'
    rc_build="${System.env.BUILD_NUMBER}"//look for BUILD_NUMBER in env (set by Jenkins)
    generatedSrcDir = file("$buildDir/generated-src")   
    jaxb_schema='src/main/resources/xsd'
    jaxbTargetDir = generatedSrcDir

}

repositories {  
// removed corporate repository details for security
jcenter()

}

configurations {
    jaxb    
}

dependencies {
    // Needed to generate JAX binding code
    jaxb 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'

}

def generatedResources = 'src/main/generated'

task jaxb(){
    description 'Converts xsds to classes'
    def jaxbTargetDir = file( generatedResources )
    jaxbTargetDir.deleteDir()

    doLast {
        jaxbTargetDir.mkdirs()

        ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: configurations.jaxb.asPath)
        ant.jaxbTargetDir = jaxbTargetDir

        ant.xjc(destdir: '${jaxbTargetDir}', package: 'com.pavan.xml.java.binding') {
                schema(dir:'src/main/resources/xsd', includes: '*.xsd')
        }       
    }
}

task generateSources(dependsOn: jaxb) {
    description 'generates the resources defined by the external xsd\'s'
}

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'src/main/generated']
        }
    }
}

compileJava.dependsOn jaxb
</code></pre>

<p>Are there any better ways to do this. I was going through this link
<a href="https://stackoverflow.com/questions/15732/whats-the-best-way-to-validate-an-xml-file-against-an-xsd-file">What&#39;s the best way to validate an XML file against an XSD file?</a> . Most of the answers are from 2008, I'm just curious whether any better ways available now to do this. </p>