On Sun, May 20, 2012 at 12:28 PM, Claus Ibsen <claus.ib...@gmail.com> wrote:
> On Sun, May 20, 2012 at 6:01 PM, Hadrian Zbarcea <hzbar...@gmail.com> > wrote: > > My vote would be for *no* auto trim. Makes things predictable and easy to > > understand. > > > > Hadrian > > > > Well yeah we should improve on this. > > What I am talking about is the XML DSLs. This is the ones where people > is struggling when you can have "spaces" around your expressions due > coding style and whatnot. > > You dont have this problem for other expressions such as xpath. This > is what you can do today > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route> > <from uri="direct:start"/> > <filter> > <xpath> > /person[@name='James'] > </xpath> > <to uri="mock:result"/> > </filter> > </route> > </camelContext> > > Which would be the same as > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route> > <from uri="direct:start"/> > <filter> > <xpath>/person[@name='James']</xpath> > <to uri="mock:result"/> > </filter> > </route> > </camelContext> > > People is most likely accustomed to the "free form" in XML, where the > "whitespace noise" is trimmed by default. > > > > > What we could do, and should do IMHO, is to add an attribute to the > expressions in Camel XML DSLs so you can turn trimming on|off. > > <simple trim="false"> > I want no trim please > And I can do as I want > </simple> > > And by having trim default to true, we can have the Camel expressions > in the XML DSL behave consistent, and not include the "whitespace > noise" by default. > > I think this is a good compromise. I understand the desire to disable auto-trim in certain cases but I think removing auto-trim altogether would cause problems for a lot of people. People are used to having freedom in formatting their XML. I think the trim option should default to true to maintain compatibility with what exists today. Chris > > > > > > On 05/20/2012 06:33 AM, Claus Ibsen wrote: > >> > >> Hi > >> > >> We have a number of JIRA tickets which is related > >> https://issues.apache.org/jira/browse/CAMEL-5294 > >> https://issues.apache.org/jira/browse/CAMEL-5285 > >> https://issues.apache.org/jira/browse/CAMEL-4990 > >> > >> When you use the XML DSLs you may have a coding style where you have > >> newlines, and spaces etc. in the text of the XML tags, eg > >> > >> <transform> > >> <simple> > >> data=${body} > >> </simple> > >> </transform> > >> > >> Notice how we have new lines in the<simple> text. > >> Below shows what the intent is without newlines: > >> > >> <transform> > >> <simple>data=${body}</simple> > >> </transform> > >> > >> Today we will auto trim Simple expressions (but not the others). IMHO > >> I think this is wrong and we should make this consistent, to either > >> - no auto trim > >> - auto trim all expressions > >> > >> If we auto trim, and you want an explicit newline, then the end user > >> can use a \n to indicate newline, eg > >> <transform> > >> <simple>data=${body}\n</simple> > >> </transform> > >> > >> I think we should go for a > >> - auto trim all expressions > >> - end users can use \n to force new lines > >> > >> Any thoughts? > >> > >> > >> > >> > > > > > > -- > Claus Ibsen > ----------------- > CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ >