Re: Question about documentType in XPathBuilder
The xml tests are likely in camel-jaxb, and potentially camel-saxon. Then you can use a spring xml file. On Mon, Jan 19, 2015 at 8:25 AM, Siano, Stephan stephan.si...@sap.com wrote: Hi Claus, Ok that does really look easy, I will prepare a patch and append it to the JIRA task. However I didn't manage to find any tests for that. In org.apache.camel.language are only tests using the Java DSL and in org.apache.camel.model and I didn't find any XPath related tests. Do you know where these tests are? Best regards Stephan -Original Message- From: Claus Ibsen [mailto:claus.ib...@gmail.com] Sent: Samstag, 17. Januar 2015 11:34 To: dev Subject: Re: Question about documentType in XPathBuilder Ad 2) I think there is already a JIRA about that. Its not so hard to do, look in the model.language packages of camel-core, and add a getter/setter and jaxb annotation for it to be in the xsd. And add the logic to configure it as well, like the other options. https://issues.apache.org/jira/browse/CAMEL-8182 [...] -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/ -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
RE: Question about documentType in XPathBuilder
Hi Claus, Ok, thanks. I didn't find anything in camel-jaxb, but camel-saxon does indeed contain some XML configurations for XPath. I extended the tests there and attached the patch to https://issues.apache.org/jira/browse/CAMEL-8182 . Is this ok? Best regards Stephan
Re: Question about documentType in XPathBuilder
Hi Thanks for the patch. On Mon, Jan 19, 2015 at 2:19 PM, Siano, Stephan stephan.si...@sap.com wrote: Hi Claus, Ok, thanks. I didn't find anything in camel-jaxb, but camel-saxon does indeed contain some XML configurations for XPath. I extended the tests there and attached the patch to https://issues.apache.org/jira/browse/CAMEL-8182 . Is this ok? Best regards Stephan -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
RE: Question about documentType in XPathBuilder
Hi Claus, Ok that does really look easy, I will prepare a patch and append it to the JIRA task. However I didn't manage to find any tests for that. In org.apache.camel.language are only tests using the Java DSL and in org.apache.camel.model and I didn't find any XPath related tests. Do you know where these tests are? Best regards Stephan -Original Message- From: Claus Ibsen [mailto:claus.ib...@gmail.com] Sent: Samstag, 17. Januar 2015 11:34 To: dev Subject: Re: Question about documentType in XPathBuilder Ad 2) I think there is already a JIRA about that. Its not so hard to do, look in the model.language packages of camel-core, and add a getter/setter and jaxb annotation for it to be in the xsd. And add the logic to configure it as well, like the other options. https://issues.apache.org/jira/browse/CAMEL-8182 [...] -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Re: Question about documentType in XPathBuilder
Ad 2) I think there is already a JIRA about that. Its not so hard to do, look in the model.language packages of camel-core, and add a getter/setter and jaxb annotation for it to be in the xsd. And add the logic to configure it as well, like the other options. https://issues.apache.org/jira/browse/CAMEL-8182 On Fri, Jan 16, 2015 at 1:52 PM, Siano, Stephan stephan.si...@sap.com wrote: Hi, If you look into the XPathBuilder in camel (actually the doInEvaluateAs() method), you see that the data that the evaluated with the XPath expression (a header or the body) is first converted into a data type defined in the documentType attribute of the XPath builder. Afterwards the expression is evaluated with the Object (or the node attribute of it if it is a DOMSource). The default for the documentType is Document (DOM), which is pretty much memory consuming. On large XML documents (e.g. 100 MB) parsing a DOM may lead to an OutOfMemoryError. If the Saxon parser is used for transformation, the implementation is capable of using a TinyTree instead of e Xerces DOM, which is much smaller, however that doesn't help if the JVM goes OOM when parsing the Document with the Xerces parser into a DOM tree even before the transformation takes place. In Java DSL it is possible to set the documentType to an XPath expression (as in) from(direct:setbody) .setBody(xpath(/a/b/c, Document.class) .documentType(SAXSource.class) .factory(new XPathFactoryImpl()) ); The route is capable of transforming much larger Documents than the same route without the .documentType(SAXSource.class) statement (InputSource will also work if the incoming data has a type converter to InputSource). In XML DSL there is unfortunately no way to set the document type. I have some questions about that: 1. Does anybody know why Document was taken as a default documentType? 2. Why is the documentType not configurable in XML DSL? What would I need to do in order to add an extra attribute to the XML DSL? 3. Wouldn't a more dynamic approach be better? E.g. if the data is a DOM tree from the beginning us that, if it's a SAXSource use that one and if it's something like an InputStream or String use an InputSource? What do you think about this? Best regards Stephan -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/