Re: Split and tokenizeXML not working with Jaxb unmarshal with Part class.
Your sample was not pasted nicely and it is not really readable. But guessing from what you described, you seem to be saying that the split result didn't exactly match the schema? In other words, some namespaces were dropped in the split result? If that is the case, that can happen when you are using tokenizeXML. To get xml-aware splitting, you should use xtokenize. see http://camel.apache.org/splitter.html 2015-12-19 14:58 GMT+01:00 sonu123: > Hi, > I have manged to make it work but with a one minor change. I found my XSD > has namepace like this > xmlns=b>urn:iso:std:iso:20022:tech:xsd:camt.086.001.01*" > xmlns:xs="http://www.w3.org/2001/XMLSchema; elementFormDefault="qualified" > targetNamespace="urn:iso:std:iso:20022:tech:xsd:camt.086.001.01"> > And my xjc generated package-info.java has > @javax.xml.bind.annotation.XmlSchema(*namespace = > "urn:iso:std:iso:20022:tech:xsd:camt.086.001.01"*, elementFormDefault = > javax.xml.bind.annotation.XmlNsForm.QUALIFIED) > I replaced the namespace with empty string > @javax.xml.bind.annotation.XmlSchema(namespace = *""*, elementFormDefault = > javax.xml.bind.annotation.XmlNsForm.QUALIFIED) > > Now I can see CurrencyExchange6 class is correctly populated. Let me know if > there are better ways of doing it. > My final codes is > @Override > public RouteBuilder createRouteBuilder() { > return new RouteBuilder() { > @Override > public void configure() throws Exception { > final JAXBContext jaxbContext = > JAXBContext.newInstance(com.main.sandeepone.CurrencyExchange6.class); > JaxbDataFormat jaxb = new JaxbDataFormat(jaxbContext); > CurrencyExchange6 c=new CurrencyExchange6(); > jaxb.setPartClass(c.getClass().getCanonicalName()); > jaxb.setFragment(true); > > from("file:target/in?noop=true=camt.086.001.01.xml").log("Content > of the ISO20022 file: ${body}") > .split() > .tokenizeXML("CcyXchg") > .streaming() .executorService(threadPool) > .log("Content of the splitted file: ${body}") >.unmarshal(jaxb) > .log("Content of the marshalled: ${body}") > .to("seda:update") > .end() > .log("Done processing the file: > ${header.CamelFileName}"); > > from("seda:update?concurrentConsumers=20") > .bean(InventoryService.class, "doSomeThingHere"); > } > }; > } > > sonu123 wrote >> Tried with stax, but not working. I am wondering, if there is any way, I >> can convert the String generated from tokenizeXML into POJO. > > > sonu123 wrote >> Tried with stax, but not working. I am wondering, if there is any way, I >> can convert the String generated from tokenizeXML into POJO. > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Split-and-tokenizeXML-not-working-with-Jaxb-unmarshal-with-Part-class-tp5775239p5775281.html > Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split and tokenizeXML not working with Jaxb unmarshal with Part class.
Hi, I have manged to make it work but with a one minor change. I found my XSD has namepace like this urn:iso:std:iso:20022:tech:xsd:camt.086.001.01*" xmlns:xs="http://www.w3.org/2001/XMLSchema; elementFormDefault="qualified" targetNamespace="urn:iso:std:iso:20022:tech:xsd:camt.086.001.01"> And my xjc generated package-info.java has @javax.xml.bind.annotation.XmlSchema(*namespace = "urn:iso:std:iso:20022:tech:xsd:camt.086.001.01"*, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) I replaced the namespace with empty string @javax.xml.bind.annotation.XmlSchema(namespace = *""*, elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) Now I can see CurrencyExchange6 class is correctly populated. Let me know if there are better ways of doing it. My final codes is @Override public RouteBuilder createRouteBuilder() { return new RouteBuilder() { @Override public void configure() throws Exception { final JAXBContext jaxbContext = JAXBContext.newInstance(com.main.sandeepone.CurrencyExchange6.class); JaxbDataFormat jaxb = new JaxbDataFormat(jaxbContext); CurrencyExchange6 c=new CurrencyExchange6(); jaxb.setPartClass(c.getClass().getCanonicalName()); jaxb.setFragment(true); from("file:target/in?noop=true=camt.086.001.01.xml").log("Content of the ISO20022 file: ${body}") .split() .tokenizeXML("CcyXchg") .streaming() .executorService(threadPool) .log("Content of the splitted file: ${body}") .unmarshal(jaxb) .log("Content of the marshalled: ${body}") .to("seda:update") .end() .log("Done processing the file: ${header.CamelFileName}"); from("seda:update?concurrentConsumers=20") .bean(InventoryService.class, "doSomeThingHere"); } }; } sonu123 wrote > Tried with stax, but not working. I am wondering, if there is any way, I > can convert the String generated from tokenizeXML into POJO. sonu123 wrote > Tried with stax, but not working. I am wondering, if there is any way, I > can convert the String generated from tokenizeXML into POJO. -- View this message in context: http://camel.465427.n5.nabble.com/Split-and-tokenizeXML-not-working-with-Jaxb-unmarshal-with-Part-class-tp5775239p5775281.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split and tokenizeXML not working with Jaxb unmarshal with Part class.
Tried with stax, but not working. I am wondering, if there is any way, I can convert the String generated from tokenizeXML into POJO. -- View this message in context: http://camel.465427.n5.nabble.com/Split-and-tokenizeXML-not-working-with-Jaxb-unmarshal-with-Part-class-tp5775239p5775245.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Split and tokenizeXML not working with Jaxb unmarshal with Part class.
Maybe try with stax it works with pojos for splitting http://camel.apache.org/stax On Fri, Dec 18, 2015 at 7:26 AM, sonu123wrote: > Hi, > > In below codes, I am reading a big XML file and then splitting on some > CcyXchg element. Until here, codes works. When I am trying to unmarshal > into Java Object, I am getting all properties of CurrencyExchange6 as null. > Any idea ho w I can convert the part XML into POJO. > public void configure() throws Exception { > JAXBContext jaxbContext = > JAXBContext.newInstance(CurrencyExchange6.class); > JaxbDataFormat jaxb = new JaxbDataFormat(jaxbContext); > jaxb.setPrettyPrint(false); > CurrencyExchange6 c=new CurrencyExchange6(); > jaxb.setPartClass(c.getClass().getCanonicalName()); > jaxb.setFragment(true); > > from("file:target/in?noop=true=camt.086.001.01.xml").log("Content > of the ISO file: ${body}") > .split().tokenizeXML("CcyXchg") > .streaming().executorService(threadPool) > .log("Content of the splitted file: ${body}") > .unmarshal(jaxb) > .log("Content of the marshalled: ${body}") > .to("seda:update") > .end() > .log("Done processing big file: > ${header.CamelFileName}"); > > from("seda:update?concurrentConsumers=20") > .bean(InventoryService.class, "doSomeThingHere"); > } > > Thanks in advance > > Regards, > Sonu > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Split-and-tokenizeXML-not-working-with-Jaxb-unmarshal-with-Part-class-tp5775239.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Split and tokenizeXML not working with Jaxb unmarshal with Part class.
Hi, In below codes, I am reading a big XML file and then splitting on some CcyXchg element. Until here, codes works. When I am trying to unmarshal into Java Object, I am getting all properties of CurrencyExchange6 as null. Any idea ho w I can convert the part XML into POJO. public void configure() throws Exception { JAXBContext jaxbContext = JAXBContext.newInstance(CurrencyExchange6.class); JaxbDataFormat jaxb = new JaxbDataFormat(jaxbContext); jaxb.setPrettyPrint(false); CurrencyExchange6 c=new CurrencyExchange6(); jaxb.setPartClass(c.getClass().getCanonicalName()); jaxb.setFragment(true); from("file:target/in?noop=true=camt.086.001.01.xml").log("Content of the ISO file: ${body}") .split().tokenizeXML("CcyXchg") .streaming().executorService(threadPool) .log("Content of the splitted file: ${body}") .unmarshal(jaxb) .log("Content of the marshalled: ${body}") .to("seda:update") .end() .log("Done processing big file: ${header.CamelFileName}"); from("seda:update?concurrentConsumers=20") .bean(InventoryService.class, "doSomeThingHere"); } Thanks in advance Regards, Sonu -- View this message in context: http://camel.465427.n5.nabble.com/Split-and-tokenizeXML-not-working-with-Jaxb-unmarshal-with-Part-class-tp5775239.html Sent from the Camel - Users mailing list archive at Nabble.com.