Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A1986173BD for ; Sat, 17 Jan 2015 10:36:27 +0000 (UTC) Received: (qmail 8788 invoked by uid 500); 17 Jan 2015 10:36:29 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 8735 invoked by uid 500); 17 Jan 2015 10:36:29 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 8719 invoked by uid 99); 17 Jan 2015 10:36:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Jan 2015 10:36:28 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.223.172 as permitted sender) Received: from [209.85.223.172] (HELO mail-ie0-f172.google.com) (209.85.223.172) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Jan 2015 10:36:04 +0000 Received: by mail-ie0-f172.google.com with SMTP id tr6so24626313ieb.3 for ; Sat, 17 Jan 2015 02:34:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=XFL/uDfm151u7obl8xG/WMx8QRLdFxaW43Zm9mqOj/E=; b=anTOcvwEn6D/bxPEB+a67E0MQXBZrLqafxi56fTZIJe7YzOH9+/KzY5e7BsA7p76Fn SatWYTRHZkV58W/JBzC8gQaW8twsOuOVK+kQtny9mxkIUq6u2Ql2E6xUrUhwW6YgMqkN gZeG4ApEPK6qZdHJkBZVom40+OflZByfIgrvGKBmkliEe94pvYEgkCAGUdRF5D0D5KjK NTVmm6HjyQ55KzmMfrXsOX6sxYJ438nbVlO//P/fUN9SU/j1DPJPhRpgu1+m9skHBVXW 41bzGc+H6zR6DTLbS8Wvm2QmlfqBTlmibT1SKYdKQ9bqr6Lg8yUkNeJCvwEsc415Dd3/ /6pg== X-Received: by 10.50.117.68 with SMTP id kc4mr8354028igb.25.1421490872662; Sat, 17 Jan 2015 02:34:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.115.100 with HTTP; Sat, 17 Jan 2015 02:34:12 -0800 (PST) In-Reply-To: References: From: Claus Ibsen Date: Sat, 17 Jan 2015 11:34:12 +0100 Message-ID: Subject: Re: Question about documentType in XPathBuilder To: dev Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org 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 wro= te: > Hi, > > If you look into the XPathBuilder in camel (actually the doInEvaluateAs()= method), you see that the data that the evaluated with the XPath expressio= n (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 le= ad 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 p= arsing 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 wil= l 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 documentTy= pe? > > 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 an= d if it's something like an InputStream or String use an InputSource? > > What do you think about this? > > Best regards > Stephan --=20 Claus Ibsen ----------------- Red Hat, Inc. Email: cibsen@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/