You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by shekher awasthi <sh...@gmail.com> on 2011/08/04 09:40:45 UTC

Custom URIResolver for Camel

we are trying to use xsl for converting xml to our custom xml format using
camel and its out of the box xslt support here is a sample route

<from uri="file://target/inventory/updates?noop=true"/>
        <unmarshal>
                <csv />
            </unmarshal>
       <to uri="bean:XMLConverter?method=processCSVInvoice" />
       <to uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
    </route>

my problem is when i am putting this xls file in the class path camel is
happily picking the xls and doing the work as per the route but moment we
are placing the xls file out of class path like in a file system camel is
unable to resolve this and we are struck as the whole purpose to use xls is
to take custom xml formatting out of the jar

as a workaround i tried to create a customURLResolver and than tried to use
it as

<from uri="file://target/inventory/updates?noop=true"/>
        <unmarshal>
                <csv />
            </unmarshal>
       <to uri="bean:XMLConverter?method=processCSVInvoice" />
       <to uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
    </route>

but in this case camel is not calling my customURIResolver any idea how i
can make camel to use my custom URIResolver in place of its default resolver



thanks in advance

Shekher

Re: Custom URIResolver for Camel

Posted by shekher awasthi <sh...@gmail.com>.
Thanks Claus  for helping me out
we have solved the issue for the time being by giving absolute path

2011/8/4 Magnus Palmér <ma...@gmail.com>

> This works fine on Linux (Ubuntu) and Tomcat:
> xslt:file:///var/opt/projectname/resources/OrderProductResponse.xsl
> Using it with Java DSL however and not Spring XML DSL, not sure it makes
> any
> difference.
>
> /Magnus
> 2011/8/4 shekher awasthi <sh...@gmail.com>
>
> > can you please elaborate what you mean by
> > " that the file is relative to where the JVM is starting"
> >
> > since i am using tomcat for my this application and my jvm is at the
> > following location
> > C:\Program Files\Java\jre6\bin\client
> >
> > i even tried to place the xsl file with respect to this jvm location but
> it
> > did not worked
> > i even tried this
> >
> >
> > <to uri=*
> >
> >
> "xslt:file://C://target//inventory//updates//xlsconvertor//filXMLConverter.xsl"
> > */>
> > and other combination but still getting the same exception
> >  On Thu, Aug 4, 2011 at 1:44 PM, Claus Ibsen <cl...@gmail.com>
> > wrote:
> >
> > > On Thu, Aug 4, 2011 at 10:00 AM, shekher awasthi
> > > <sh...@gmail.com> wrote:
> > > > thanks Claus for the reply
> > > >  i tried even like this
> > > >
> > > > <to uri=*
> > > >
> > >
> >
> "xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
> > > > */>
> > > >
> > > > and even
> > > >
> > > > <to uri=*
> > > >
> > >
> >
> "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
> > > >  for the first part its giving me the foloowing exception
> > > >
> > > > org.apache.camel.RuntimeCamelException:
> > > > org.apache.camel.FailedToCreateRouteException: Failed to create route
> > > tutu
> > > > at: >>>
> > > >
> > >
> >
> To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
> > > > <<< in route: Route[[From[file://target/inve
> > > > ntory/updates?noop=true]] -> [... because of Failed to resolve
> > endpoint:
> > > >
> > >
> >
> xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
> > > > due to: target URL [file://target/inventory/updates/xlsconvertor]
> > > >
> > > > i am still clueless what i am doing wrong
> > >
> > > There is no fileName option on this component, use
> > >
> > >
>  "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"
> > >
> > > Mind that the file is relative to where the JVM is starting. You can
> > > use an absolute path if you add an extra slash.
> > >
> > > >
> > > > On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com>
> > > wrote:
> > > >
> > > >> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
> > > >> <sh...@gmail.com> wrote:
> > > >> > we are trying to use xsl for converting xml to our custom xml
> format
> > > >> using
> > > >> > camel and its out of the box xslt support here is a sample route
> > > >> >
> > > >> > <from uri="file://target/inventory/updates?noop=true"/>
> > > >> >        <unmarshal>
> > > >> >                <csv />
> > > >> >            </unmarshal>
> > > >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> > > >> >       <to
> > > >>
> > >
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
> > > >> >      <to
> > > uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> > > >> >    </route>
> > > >> >
> > > >> > my problem is when i am putting this xls file in the class path
> > camel
> > > is
> > > >> > happily picking the xls and doing the work as per the route but
> > moment
> > > we
> > > >> > are placing the xls file out of class path like in a file system
> > camel
> > > is
> > > >> > unable to resolve this and we are struck as the whole purpose to
> use
> > > xls
> > > >> is
> > > >> > to take custom xml formatting out of the jar
> > > >> >
> > > >>
> > > >> By default the xslt looks in the classpath. If you want to read from
> > > >> the file system, you need to prefix with file://
> > > >> Notice the colon.
> > > >>
> > > >> Its documented here:
> > > >> http://camel.apache.org/xslt
> > > >>
> > > >>
> > > >> > as a workaround i tried to create a customURLResolver and than
> tried
> > > to
> > > >> use
> > > >> > it as
> > > >> >
> > > >> > <from uri="file://target/inventory/updates?noop=true"/>
> > > >> >        <unmarshal>
> > > >> >                <csv />
> > > >> >            </unmarshal>
> > > >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> > > >> >       <to
> > > >>
> > >
> >
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
> > > >> >      <to
> > > uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> > > >> >    </route>
> > > >> >
> > > >> > but in this case camel is not calling my customURIResolver any
> idea
> > > how i
> > > >> > can make camel to use my custom URIResolver in place of its
> default
> > > >> resolver
> > > >> >
> > > >> >
> > > >> >
> > > >> > thanks in advance
> > > >> >
> > > >> > Shekher
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >> --
> > > >> Claus Ibsen
> > > >> -----------------
> > > >> FuseSource
> > > >> Email: cibsen@fusesource.com
> > > >> Web: http://fusesource.com
> > > >> Twitter: davsclaus, fusenews
> > > >> Blog: http://davsclaus.blogspot.com/
> > > >> Author of Camel in Action: http://www.manning.com/ibsen/
> > > >>
> > > >
> > >
> > >
> > >
> > > --
> > >  Claus Ibsen
> > > -----------------
> > > FuseSource
> > > Email: cibsen@fusesource.com
> > > Web: http://fusesource.com
> > > Twitter: davsclaus, fusenews
> > > Blog: http://davsclaus.blogspot.com/
> > > Author of Camel in Action: http://www.manning.com/ibsen/
> > >
> >
>

Re: Custom URIResolver for Camel

Posted by Magnus Palmér <ma...@gmail.com>.
This works fine on Linux (Ubuntu) and Tomcat:
xslt:file:///var/opt/projectname/resources/OrderProductResponse.xsl
Using it with Java DSL however and not Spring XML DSL, not sure it makes any
difference.

/Magnus
2011/8/4 shekher awasthi <sh...@gmail.com>

> can you please elaborate what you mean by
> " that the file is relative to where the JVM is starting"
>
> since i am using tomcat for my this application and my jvm is at the
> following location
> C:\Program Files\Java\jre6\bin\client
>
> i even tried to place the xsl file with respect to this jvm location but it
> did not worked
> i even tried this
>
>
> <to uri=*
>
> "xslt:file://C://target//inventory//updates//xlsconvertor//filXMLConverter.xsl"
> */>
> and other combination but still getting the same exception
>  On Thu, Aug 4, 2011 at 1:44 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
>
> > On Thu, Aug 4, 2011 at 10:00 AM, shekher awasthi
> > <sh...@gmail.com> wrote:
> > > thanks Claus for the reply
> > >  i tried even like this
> > >
> > > <to uri=*
> > >
> >
> "xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
> > > */>
> > >
> > > and even
> > >
> > > <to uri=*
> > >
> >
> "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
> > >  for the first part its giving me the foloowing exception
> > >
> > > org.apache.camel.RuntimeCamelException:
> > > org.apache.camel.FailedToCreateRouteException: Failed to create route
> > tutu
> > > at: >>>
> > >
> >
> To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
> > > <<< in route: Route[[From[file://target/inve
> > > ntory/updates?noop=true]] -> [... because of Failed to resolve
> endpoint:
> > >
> >
> xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
> > > due to: target URL [file://target/inventory/updates/xlsconvertor]
> > >
> > > i am still clueless what i am doing wrong
> >
> > There is no fileName option on this component, use
> >
> >  "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"
> >
> > Mind that the file is relative to where the JVM is starting. You can
> > use an absolute path if you add an extra slash.
> >
> > >
> > > On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com>
> > wrote:
> > >
> > >> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
> > >> <sh...@gmail.com> wrote:
> > >> > we are trying to use xsl for converting xml to our custom xml format
> > >> using
> > >> > camel and its out of the box xslt support here is a sample route
> > >> >
> > >> > <from uri="file://target/inventory/updates?noop=true"/>
> > >> >        <unmarshal>
> > >> >                <csv />
> > >> >            </unmarshal>
> > >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> > >> >       <to
> > >>
> > uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
> > >> >      <to
> > uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> > >> >    </route>
> > >> >
> > >> > my problem is when i am putting this xls file in the class path
> camel
> > is
> > >> > happily picking the xls and doing the work as per the route but
> moment
> > we
> > >> > are placing the xls file out of class path like in a file system
> camel
> > is
> > >> > unable to resolve this and we are struck as the whole purpose to use
> > xls
> > >> is
> > >> > to take custom xml formatting out of the jar
> > >> >
> > >>
> > >> By default the xslt looks in the classpath. If you want to read from
> > >> the file system, you need to prefix with file://
> > >> Notice the colon.
> > >>
> > >> Its documented here:
> > >> http://camel.apache.org/xslt
> > >>
> > >>
> > >> > as a workaround i tried to create a customURLResolver and than tried
> > to
> > >> use
> > >> > it as
> > >> >
> > >> > <from uri="file://target/inventory/updates?noop=true"/>
> > >> >        <unmarshal>
> > >> >                <csv />
> > >> >            </unmarshal>
> > >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> > >> >       <to
> > >>
> >
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
> > >> >      <to
> > uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> > >> >    </route>
> > >> >
> > >> > but in this case camel is not calling my customURIResolver any idea
> > how i
> > >> > can make camel to use my custom URIResolver in place of its default
> > >> resolver
> > >> >
> > >> >
> > >> >
> > >> > thanks in advance
> > >> >
> > >> > Shekher
> > >> >
> > >>
> > >>
> > >>
> > >> --
> > >> Claus Ibsen
> > >> -----------------
> > >> FuseSource
> > >> Email: cibsen@fusesource.com
> > >> Web: http://fusesource.com
> > >> Twitter: davsclaus, fusenews
> > >> Blog: http://davsclaus.blogspot.com/
> > >> Author of Camel in Action: http://www.manning.com/ibsen/
> > >>
> > >
> >
> >
> >
> > --
> >  Claus Ibsen
> > -----------------
> > FuseSource
> > Email: cibsen@fusesource.com
> > Web: http://fusesource.com
> > Twitter: davsclaus, fusenews
> > Blog: http://davsclaus.blogspot.com/
> > Author of Camel in Action: http://www.manning.com/ibsen/
> >
>

Re: Custom URIResolver for Camel

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I found a bug in the camel xslt component and have logged a ticket and
work on a fix
https://issues.apache.org/jira/browse/CAMEL-4305

On Thu, Aug 4, 2011 at 10:48 AM, shekher awasthi
<sh...@gmail.com> wrote:
> can you please elaborate what you mean by
> " that the file is relative to where the JVM is starting"
>
> since i am using tomcat for my this application and my jvm is at the
> following location
> C:\Program Files\Java\jre6\bin\client
>
> i even tried to place the xsl file with respect to this jvm location but it
> did not worked
> i even tried this
>
>
> <to uri=*
> "xslt:file://C://target//inventory//updates//xlsconvertor//filXMLConverter.xsl"
> */>
> and other combination but still getting the same exception
> On Thu, Aug 4, 2011 at 1:44 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Thu, Aug 4, 2011 at 10:00 AM, shekher awasthi
>> <sh...@gmail.com> wrote:
>> > thanks Claus for the reply
>> >  i tried even like this
>> >
>> > <to uri=*
>> >
>> "xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
>> > */>
>> >
>> > and even
>> >
>> > <to uri=*
>> >
>> "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
>> >  for the first part its giving me the foloowing exception
>> >
>> > org.apache.camel.RuntimeCamelException:
>> > org.apache.camel.FailedToCreateRouteException: Failed to create route
>> tutu
>> > at: >>>
>> >
>> To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
>> > <<< in route: Route[[From[file://target/inve
>> > ntory/updates?noop=true]] -> [... because of Failed to resolve endpoint:
>> >
>> xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
>> > due to: target URL [file://target/inventory/updates/xlsconvertor]
>> >
>> > i am still clueless what i am doing wrong
>>
>> There is no fileName option on this component, use
>>
>>  "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"
>>
>> Mind that the file is relative to where the JVM is starting. You can
>> use an absolute path if you add an extra slash.
>>
>> >
>> > On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com>
>> wrote:
>> >
>> >> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
>> >> <sh...@gmail.com> wrote:
>> >> > we are trying to use xsl for converting xml to our custom xml format
>> >> using
>> >> > camel and its out of the box xslt support here is a sample route
>> >> >
>> >> > <from uri="file://target/inventory/updates?noop=true"/>
>> >> >        <unmarshal>
>> >> >                <csv />
>> >> >            </unmarshal>
>> >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>> >> >       <to
>> >>
>> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
>> >> >      <to
>> uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>> >> >    </route>
>> >> >
>> >> > my problem is when i am putting this xls file in the class path camel
>> is
>> >> > happily picking the xls and doing the work as per the route but moment
>> we
>> >> > are placing the xls file out of class path like in a file system camel
>> is
>> >> > unable to resolve this and we are struck as the whole purpose to use
>> xls
>> >> is
>> >> > to take custom xml formatting out of the jar
>> >> >
>> >>
>> >> By default the xslt looks in the classpath. If you want to read from
>> >> the file system, you need to prefix with file://
>> >> Notice the colon.
>> >>
>> >> Its documented here:
>> >> http://camel.apache.org/xslt
>> >>
>> >>
>> >> > as a workaround i tried to create a customURLResolver and than tried
>> to
>> >> use
>> >> > it as
>> >> >
>> >> > <from uri="file://target/inventory/updates?noop=true"/>
>> >> >        <unmarshal>
>> >> >                <csv />
>> >> >            </unmarshal>
>> >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>> >> >       <to
>> >>
>> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
>> >> >      <to
>> uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>> >> >    </route>
>> >> >
>> >> > but in this case camel is not calling my customURIResolver any idea
>> how i
>> >> > can make camel to use my custom URIResolver in place of its default
>> >> resolver
>> >> >
>> >> >
>> >> >
>> >> > thanks in advance
>> >> >
>> >> > Shekher
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Claus Ibsen
>> >> -----------------
>> >> FuseSource
>> >> Email: cibsen@fusesource.com
>> >> Web: http://fusesource.com
>> >> Twitter: davsclaus, fusenews
>> >> Blog: http://davsclaus.blogspot.com/
>> >> Author of Camel in Action: http://www.manning.com/ibsen/
>> >>
>> >
>>
>>
>>
>> --
>>  Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Custom URIResolver for Camel

Posted by shekher awasthi <sh...@gmail.com>.
can you please elaborate what you mean by
" that the file is relative to where the JVM is starting"

since i am using tomcat for my this application and my jvm is at the
following location
C:\Program Files\Java\jre6\bin\client

i even tried to place the xsl file with respect to this jvm location but it
did not worked
i even tried this


<to uri=*
"xslt:file://C://target//inventory//updates//xlsconvertor//filXMLConverter.xsl"
*/>
and other combination but still getting the same exception
On Thu, Aug 4, 2011 at 1:44 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Aug 4, 2011 at 10:00 AM, shekher awasthi
> <sh...@gmail.com> wrote:
> > thanks Claus for the reply
> >  i tried even like this
> >
> > <to uri=*
> >
> "xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
> > */>
> >
> > and even
> >
> > <to uri=*
> >
> "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
> >  for the first part its giving me the foloowing exception
> >
> > org.apache.camel.RuntimeCamelException:
> > org.apache.camel.FailedToCreateRouteException: Failed to create route
> tutu
> > at: >>>
> >
> To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
> > <<< in route: Route[[From[file://target/inve
> > ntory/updates?noop=true]] -> [... because of Failed to resolve endpoint:
> >
> xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
> > due to: target URL [file://target/inventory/updates/xlsconvertor]
> >
> > i am still clueless what i am doing wrong
>
> There is no fileName option on this component, use
>
>  "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"
>
> Mind that the file is relative to where the JVM is starting. You can
> use an absolute path if you add an extra slash.
>
> >
> > On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com>
> wrote:
> >
> >> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
> >> <sh...@gmail.com> wrote:
> >> > we are trying to use xsl for converting xml to our custom xml format
> >> using
> >> > camel and its out of the box xslt support here is a sample route
> >> >
> >> > <from uri="file://target/inventory/updates?noop=true"/>
> >> >        <unmarshal>
> >> >                <csv />
> >> >            </unmarshal>
> >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> >> >       <to
> >>
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
> >> >      <to
> uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> >> >    </route>
> >> >
> >> > my problem is when i am putting this xls file in the class path camel
> is
> >> > happily picking the xls and doing the work as per the route but moment
> we
> >> > are placing the xls file out of class path like in a file system camel
> is
> >> > unable to resolve this and we are struck as the whole purpose to use
> xls
> >> is
> >> > to take custom xml formatting out of the jar
> >> >
> >>
> >> By default the xslt looks in the classpath. If you want to read from
> >> the file system, you need to prefix with file://
> >> Notice the colon.
> >>
> >> Its documented here:
> >> http://camel.apache.org/xslt
> >>
> >>
> >> > as a workaround i tried to create a customURLResolver and than tried
> to
> >> use
> >> > it as
> >> >
> >> > <from uri="file://target/inventory/updates?noop=true"/>
> >> >        <unmarshal>
> >> >                <csv />
> >> >            </unmarshal>
> >> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> >> >       <to
> >>
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
> >> >      <to
> uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> >> >    </route>
> >> >
> >> > but in this case camel is not calling my customURIResolver any idea
> how i
> >> > can make camel to use my custom URIResolver in place of its default
> >> resolver
> >> >
> >> >
> >> >
> >> > thanks in advance
> >> >
> >> > Shekher
> >> >
> >>
> >>
> >>
> >> --
> >> Claus Ibsen
> >> -----------------
> >> FuseSource
> >> Email: cibsen@fusesource.com
> >> Web: http://fusesource.com
> >> Twitter: davsclaus, fusenews
> >> Blog: http://davsclaus.blogspot.com/
> >> Author of Camel in Action: http://www.manning.com/ibsen/
> >>
> >
>
>
>
> --
>  Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: Custom URIResolver for Camel

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 4, 2011 at 10:00 AM, shekher awasthi
<sh...@gmail.com> wrote:
> thanks Claus for the reply
>  i tried even like this
>
> <to uri=*
> "xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
> */>
>
> and even
>
> <to uri=*
> "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
>  for the first part its giving me the foloowing exception
>
> org.apache.camel.RuntimeCamelException:
> org.apache.camel.FailedToCreateRouteException: Failed to create route tutu
> at: >>>
> To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
> <<< in route: Route[[From[file://target/inve
> ntory/updates?noop=true]] -> [... because of Failed to resolve endpoint:
> xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
> due to: target URL [file://target/inventory/updates/xlsconvertor]
>
> i am still clueless what i am doing wrong

There is no fileName option on this component, use

 "xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"

Mind that the file is relative to where the JVM is starting. You can
use an absolute path if you add an extra slash.

>
> On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com> wrote:
>
>> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
>> <sh...@gmail.com> wrote:
>> > we are trying to use xsl for converting xml to our custom xml format
>> using
>> > camel and its out of the box xslt support here is a sample route
>> >
>> > <from uri="file://target/inventory/updates?noop=true"/>
>> >        <unmarshal>
>> >                <csv />
>> >            </unmarshal>
>> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>> >       <to
>> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
>> >      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>> >    </route>
>> >
>> > my problem is when i am putting this xls file in the class path camel is
>> > happily picking the xls and doing the work as per the route but moment we
>> > are placing the xls file out of class path like in a file system camel is
>> > unable to resolve this and we are struck as the whole purpose to use xls
>> is
>> > to take custom xml formatting out of the jar
>> >
>>
>> By default the xslt looks in the classpath. If you want to read from
>> the file system, you need to prefix with file://
>> Notice the colon.
>>
>> Its documented here:
>> http://camel.apache.org/xslt
>>
>>
>> > as a workaround i tried to create a customURLResolver and than tried to
>> use
>> > it as
>> >
>> > <from uri="file://target/inventory/updates?noop=true"/>
>> >        <unmarshal>
>> >                <csv />
>> >            </unmarshal>
>> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>> >       <to
>> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
>> >      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>> >    </route>
>> >
>> > but in this case camel is not calling my customURIResolver any idea how i
>> > can make camel to use my custom URIResolver in place of its default
>> resolver
>> >
>> >
>> >
>> > thanks in advance
>> >
>> > Shekher
>> >
>>
>>
>>
>> --
>> Claus Ibsen
>> -----------------
>> FuseSource
>> Email: cibsen@fusesource.com
>> Web: http://fusesource.com
>> Twitter: davsclaus, fusenews
>> Blog: http://davsclaus.blogspot.com/
>> Author of Camel in Action: http://www.manning.com/ibsen/
>>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: Custom URIResolver for Camel

Posted by shekher awasthi <sh...@gmail.com>.
thanks Claus for the reply
 i tried even like this

<to uri=*
"xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl"
*/>

and even

<to uri=*
"xslt:file://target/inventory/updates/xlsconvertor/filXMLConverter.xsl"*/>
 for the first part its giving me the foloowing exception

org.apache.camel.RuntimeCamelException:
org.apache.camel.FailedToCreateRouteException: Failed to create route tutu
at: >>>
To[xslt:file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl]
<<< in route: Route[[From[file://target/inve
ntory/updates?noop=true]] -> [... because of Failed to resolve endpoint:
xslt://file://target/inventory/updates/xlsconvertor?fileName=filXMLConverter.xsl
due to: target URL [file://target/inventory/updates/xlsconvertor]

i am still clueless what i am doing wrong

On Thu, Aug 4, 2011 at 1:19 PM, Claus Ibsen <cl...@gmail.com> wrote:

> On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
> <sh...@gmail.com> wrote:
> > we are trying to use xsl for converting xml to our custom xml format
> using
> > camel and its out of the box xslt support here is a sample route
> >
> > <from uri="file://target/inventory/updates?noop=true"/>
> >        <unmarshal>
> >                <csv />
> >            </unmarshal>
> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> >       <to
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
> >      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> >    </route>
> >
> > my problem is when i am putting this xls file in the class path camel is
> > happily picking the xls and doing the work as per the route but moment we
> > are placing the xls file out of class path like in a file system camel is
> > unable to resolve this and we are struck as the whole purpose to use xls
> is
> > to take custom xml formatting out of the jar
> >
>
> By default the xslt looks in the classpath. If you want to read from
> the file system, you need to prefix with file://
> Notice the colon.
>
> Its documented here:
> http://camel.apache.org/xslt
>
>
> > as a workaround i tried to create a customURLResolver and than tried to
> use
> > it as
> >
> > <from uri="file://target/inventory/updates?noop=true"/>
> >        <unmarshal>
> >                <csv />
> >            </unmarshal>
> >       <to uri="bean:XMLConverter?method=processCSVInvoice" />
> >       <to
> uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
> >      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
> >    </route>
> >
> > but in this case camel is not calling my customURIResolver any idea how i
> > can make camel to use my custom URIResolver in place of its default
> resolver
> >
> >
> >
> > thanks in advance
> >
> > Shekher
> >
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/
>

Re: Custom URIResolver for Camel

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Aug 4, 2011 at 9:40 AM, shekher awasthi
<sh...@gmail.com> wrote:
> we are trying to use xsl for converting xml to our custom xml format using
> camel and its out of the box xslt support here is a sample route
>
> <from uri="file://target/inventory/updates?noop=true"/>
>        <unmarshal>
>                <csv />
>            </unmarshal>
>       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>       <to uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl"/>
>      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>    </route>
>
> my problem is when i am putting this xls file in the class path camel is
> happily picking the xls and doing the work as per the route but moment we
> are placing the xls file out of class path like in a file system camel is
> unable to resolve this and we are struck as the whole purpose to use xls is
> to take custom xml formatting out of the jar
>

By default the xslt looks in the classpath. If you want to read from
the file system, you need to prefix with file://
Notice the colon.

Its documented here:
http://camel.apache.org/xslt


> as a workaround i tried to create a customURLResolver and than tried to use
> it as
>
> <from uri="file://target/inventory/updates?noop=true"/>
>        <unmarshal>
>                <csv />
>            </unmarshal>
>       <to uri="bean:XMLConverter?method=processCSVInvoice" />
>       <to uri="xslt:file//target/inventory/updates/xlsconvertor/XMLConverter.xsl?uriResolver=customURIResolver"/>
>      <to uri="file://target/inventory/updates/test?fileName=test11.xml"/>
>    </route>
>
> but in this case camel is not calling my customURIResolver any idea how i
> can make camel to use my custom URIResolver in place of its default resolver
>
>
>
> thanks in advance
>
> Shekher
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/