you are talking about the invalid-xml parsing bug in xtokenzier. that has been fixe with CAMEL-8106. It should be part of the new 2.14.1, which is to be released shortly.
regards, aki 2014-12-10 9:25 GMT+01:00 Jan Matèrne (jhm) <apa...@materne.de>: > I played a little bit. > > Jan > > > public class XmlTest extends CamelTestSupport { > > @EndpointInject(uri="mock:valid") > MockEndpoint valid; > > @EndpointInject(uri="mock:validationError") > MockEndpoint validationError; > > > > @Test > public void validNewsfeed() throws Exception { > // Newsfeed contains 2 news > valid.expectedMessageCount(2); > valid.expectedMessagesMatches( > // Use helper methods from the static imported PredicateBuilder > and( > header("newsfeed.date").isEqualTo("2014.12.09 14:15"), > header("news.author").isEqualTo("Jan"), > > body().contains("xmlns:news=\"http://www.materne.de/camel/test/xml/complex/\ > "") > ) > ); > // no error expected > validationError.expectedMessageCount(0); > > // Read xml from classpath and send to Camel route > String xml = > IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/test/xml/ > complex/validNewsfeed.xml")); > sendBody("direct:in", xml); > > // 'execute' all tests > assertMockEndpointsSatisfied(); > } > > > @Test > public void invalidXml() throws Exception { > valid.expectedMessageCount(0); > validationError.expectedMessageCount(1); > > String xml = "<xml/>"; > sendBody("direct:in", xml); > > assertMockEndpointsSatisfied(); > } > > > > @Override > protected RouteBuilder createRouteBuilder() throws Exception { > return new RouteBuilder() { > @Override > public void configure() throws Exception { > // Our XML uses namespaces, so we have to deal with that. > Namespaces ns = new Namespaces("news", > "http://www.materne.de/camel/test/xml/complex/"); > > // XSD-invalid data goes to this endpoint > onException(ValidationException.class) > .to("mock:validationError"); > > from("direct:in") > // XSD-validation > > .to("validator:de/materne/camel/test/xml/complex/newsfeed.xsd") > > // Store newsfeed data in the header before split, so we > haven't to do that on each > // splittet news-message. > .setHeader("newsfeed.date", > ns.xpath("/news:Newsletter/@date", String.class)) > > // http://camel.apache.org/splitter.html > // xtokenize() is available since Camel 2.14. > // Use the 'wrap'-mode so we keep the Newsletter-Header > .split().xtokenize("/news:Newsletter/News", 'w', ns) > > // Workaround of a bug?? in XMLTokenizerExpression > .setBody(simple("${body.replace('</</news:Newsletter>', > '</news:Newsletter>')}")) > .setBody(simple("${body.replace('<</news:Newsletter>', > '</news:Newsletter>')}")) > > // Get some data from the splittet news > .setHeader("news.date", > ns.xpath("/news:Newsletter/News/@date", String.class)) > .setHeader("news.author", > ns.xpath("/news:Newsletter//News/@author", String.class)) > > .to("mock:valid"); > } > }; > } > > } > > > > <?xml version="1.0" encoding="UTF-8"?> > <schema > xmlns="http://www.w3.org/2001/XMLSchema" > xmlns:news="http://www.materne.de/camel/test/xml/complex/" > targetNamespace="http://www.materne.de/camel/test/xml/complex/"> > > <element name="Newsletter"> > <complexType> > <sequence> > <element name="News" minOccurs="1" > maxOccurs="unbounded"> > <complexType> > <simpleContent> > <extension > base="string"> > <attribute > name="date" type="string"/> > <attribute > name="author" type="string"/> > </extension> > </simpleContent> > </complexType> > </element> > </sequence> > <attribute name="date" type="string"/> > </complexType> > </element> > > </schema> > > > > <news:Newsletter > xmlns:news="http://www.materne.de/camel/test/xml/complex/" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://www.materne.de/camel/test/xml/complex/ > newsfeed.xsd " > date="2014.12.09 14:15"> > <News date="2014.12.09 14:15" author="Jan"> > Here is a demo news. > </News> > <News date="2014.12.09 14:13" author="Jan"> > Second news paragraph. > </News> > </news:Newsletter> > > > >> -----Ursprüngliche Nachricht----- >> Von: smilevasu6 [mailto:srinivas.thu...@gmail.com] >> Gesendet: Dienstag, 9. Dezember 2014 15:12 >> An: users@camel.apache.org >> Betreff: Re: AW: camel - xsd >> >> Don't mind can you give me sample code instead of link >> >> >> >> -- >> View this message in context: http://camel.465427.n5.nabble.com/camel- >> xsd-tp5760376p5760396.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >