I stripped down my own example and did a cross check to yours: When running on Java 1.8.0_20-ea-b20 the test failed. When I add Woodstox 4.4.1 as dependency the test passed.
Same results when using Java 1.9.0-ea-b06. https://camel.apache.org/splitter.html sais "Note that this StAX based tokenizer's uses StAX Location API and requires a StAX Reader implementation (e.g., woodstox) that correctly returns the offset position pointing to the beginning of each event triggering segment (e.g., the offset position of '<' at each start and end element event)." As we found the reason for the "error", should I update that paragraph to say something about the consequences of a missing StAX-with-Location? Jan > -----Ursprüngliche Nachricht----- > Von: Jan Matèrne (jhm) [mailto:apa...@materne.de] > Gesendet: Dienstag, 16. Dezember 2014 10:19 > An: users@camel.apache.org > Betreff: AW: AW: camel - xsd > > Sorry for my late answer, I was ill :( > > Thanks for your sample project, I investigated into it now. > All tests passed. (Camel 2.14.0) > > But your test used the XMLTokenExpressionIterator directly I migrated > my own test class (using the RouteBuilder) into your project. > - added the test class > - added the xsd > - added the dependency to commons-io + camel-test-spring > - changed the paths in my test class to fit your directory layout Now > this also passed. > > It's good to see that there is no bug in Camel. ;) > > > Because my example still fails in my other environment I check that ... > > > Jan > > > > -----Ursprüngliche Nachricht----- > > Von: Aki Yoshida [mailto:elak...@gmail.com] > > Gesendet: Mittwoch, 10. Dezember 2014 23:57 > > An: users@camel.apache.org > > Betreff: Re: AW: camel - xsd > > > > i meant woodstox-core-asl (e.g., woodstox-core-asl-4.4.1.jar). > > its maven coordinate is > > > > mvn:org.codehaus.woodstox/woodstox-core-asl/4.4.1 > > > > you need to have woodstox or some other parser that reliably reports > > the offset location at each parse event. > > Sjsxp (sun/oracle implementation included in JDK) doesn't do that, so > > you can't use it. > > > > jmtest.tar.gz contains a maven project that can be executed directly > > by typing mvn test at the console or can be imported into your > eclipse > > IDE. > > > > 2014-12-10 13:13 GMT+01:00 Aki Yoshida <elak...@gmail.com>: > > > i just created a test that uses your data and verified that it is > > working fine. > > > please take a look at this file at my dropbox. > > > https://www.dropbox.com/s/pfgvs9si9bvujxo/jmtest.tar.gz?dl=0 > > > just extract the files into camel-core and run JMNewsTest. > > > and see if that works in your environment, (i believe it does). > > > > > > in that case, we need to find out the difference to your case. > > > do you have woodstox-api in your class path? > > > > > > > > > 2014-12-10 12:15 GMT+01:00 Aki Yoshida <elak...@gmail.com>: > > >> okay. > > >> let me take a look. > > >> > > >> > > >> 2014-12-10 12:02 GMT+01:00 Jan Matèrne (jhm) <apa...@materne.de>: > > >>> No, input is valid xml. > > >>> After invoking xtokenize() the xml is invalid. > > >>> > > >>> CAMEL-8106 is very .... short. I can't see whether it is related. > > >>> > > >>> > > >>> I posted an example on the user list > > >>> http://mail-archives.apache.org/mod_mbox/camel- > > users/201412.mbox/%3C > > >>> 002b01d01452%24e8ee27a0%24baca76e0%24%40de%3E > > >>> > > >>> I had done a 'workaround' for this special example > > >>> // Workaround of a bug?? in XMLTokenizerExpression > > >>> .setBody(simple("${body.replace('</</news:Newsletter>', > > '</news:Newsletter>')}")) > > >>> .setBody(simple("${body.replace('<</news:Newsletter>', > > >>> '</news:Newsletter>')}")) > > >>> > > >>> Without that the split messages have wrong end tags. > > >>> > > >>> > > >>> Jan > > >>> > > >>> > > >>>> -----Ursprüngliche Nachricht----- > > >>>> Von: Aki Yoshida [mailto:elak...@gmail.com] > > >>>> Gesendet: Mittwoch, 10. Dezember 2014 10:34 > > >>>> An: users@camel.apache.org > > >>>> Betreff: Re: AW: camel - xsd > > >>>> > > >>>> 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/ > > >>>> com > > >>>> > plex/\ > > >>>> > "") > > >>>> > ) > > >>>> > ); > > >>>> > // no error expected > > >>>> > validationError.expectedMessageCount(0); > > >>>> > > > >>>> > // Read xml from classpath and send to Camel route > > >>>> > String xml = > > >>>> > > > >>>> > > IOUtils.toString(getClass().getResourceAsStream("/de/materne/camel/ > > >>>> tes > > >>>> > t/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. > > >>>> > > > >>>