My aim is to read a CSV file, convert it to an XML and validate it against an XSD. Below is the code:
CamelContext _ctx = new DefaultCamelContext();
_ctx.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from("file:src/main/resources?fileName=data-sample.csv")
.process(new MyTransformValidator())
.to("file:src/main/resources/?fileName=emp.xml")
.to("validator:src/main/resources?fileName=SampleXMLStructure.xsd");
}
});
Error:
Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[validator:src/main/resources?fileName=SampleXMLStructure.xsd] <<< in route: Route(route1)[From[file:src/main/resources?fileName=data-sam... because of Failed to resolve endpoint: validator://src/main/resources?fileName=SampleXMLStructure.xsd due to: Failed to resolve endpoint: validator://src/main/resources?fileName=SampleXMLStructure.xsd due to: There are 1 parameters that couldn't be set on the endpoint. Check the uri if the parameters are spelt correctly and that they are properties of the endpoint. Unknown parameters=[{fileName=SampleXMLStructure.xsd}]
Also,I would like to configure if some Exception occurs if the XML is not valid for the given XSD. How do we configure this?
Please kindly help.
With exception block try like this: