Hi all,
I'm using the following code where url is a variable passed from java main prog, and elemtURL are links extracted withing a loop list
<xq-param name="doc"> <html-to-xml> <http url="${sys.fullUrl(url.toString().replace('/pewpew', ''), elemtURL)}"/> </html-to-xml> </xq-param>
the url looks like: http://www.example.com/pewpew and elemtURL="/pewpew/groupA"
so I'm trying to concatenate these two variables to get a valid url, but I get this error:
org.webharvest.exception.ScriptException: Error during script execution: Sourced file: inline evaluation of: ``sys.fullUrl(url.toString().replace('/pewpew', ''), elemtURL);'' Token Parsing Error: Lexical error at line 1, column 38. Encountered: "p" (112), after : "\'/" at org.webharvest.runtime.scripting.BeanShellScriptEngine.eval(Unknown Source) at org.webharvest.runtime.templaters.BaseTemplater.execute(Unknown Source) at org.webharvest.runtime.processors.HttpProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.BodyProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.HtmlToXmlProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.BodyProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.XQueryProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.BodyProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.LoopProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.processors.BodyProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.getBodyTextContent(Unknown Source) at org.webharvest.runtime.processors.FileProcessor.executeFileWrite(Unknown Source) at org.webharvest.runtime.processors.FileProcessor.execute(Unknown Source) at org.webharvest.runtime.processors.BaseProcessor.run(Unknown Source) at org.webharvest.runtime.Scraper.execute(Unknown Source) at org.webharvest.runtime.Scraper.execute(Unknown Source) at test.main(test.java:53) Caused by: Sourced file: inline evaluation of: ``sys.fullUrl(url.toString().replace('/pewpew', ''), elemtURL);'' Token Parsing Error: Lexical error at line 1, column 38. Encountered: "p" (112), after : "\'/": <at unknown location> at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) at bsh.Interpreter.eval(Unknown Source) ... 29 more
any idea how to fix this?
Maybe you have to escape '/' character in '/pewpew' string.
Try something like this:
<http url="${sys.fullUrl(url.toString().replace('\\/pewpew', ''), elemtURL)}"/>
Or remove '/' character from replace method, it won't be removed and when concating you will have double //, but it shouln't make a problem in URL.
When using the backslash I get:
org.webharvest.exception.ScriptException: Error during script execution: Sourced file: inline evaluation of: ``sys.fullUrl(url.toString().replace('\/pewpew', ''), elemtURL);'' Token Parsing Error: Lexical error at line 1, column 38. Encountered: "/" (47), after : "\'\\"
And when removing both the slash and backslash:
org.webharvest.exception.ScriptException: Error during script execution: Sourced file: inline evaluation of: ``sys.fullUrl(url.toString().replace('pewpew', ''), elemtURL);'' Token Parsing Error: Lexical error at line 1, column 38. Encountered: "e" (108), after : "\'p"
I really dont understand what's wrong xD
Well, finally it works using simply this: ${sys.fullUrl(url.toString(), catURL.toString())}
And also correcting my Xpath >.>
Thanks for your help :-)
Ah, the problem was in single qoutes. I just realised that. You should write replace("some string",....).
It works like a charm.... thanks :)
No problem ;)
Log in to post a comment.
Hi all,
I'm using the following code where url is a variable passed from java main
prog, and elemtURL are links extracted withing a loop list
the url looks like:
http://www.example.com/pewpew and
elemtURL="/pewpew/groupA"
so I'm trying to concatenate these two variables to get a valid url, but I get
this error:
any idea how to fix this?
Maybe you have to escape '/' character in '/pewpew' string.
Try something like this:
<http url="${sys.fullUrl(url.toString().replace('\\/pewpew', ''), elemtURL)}"/>
Or remove '/' character from replace method, it won't be removed and when
concating you will have double //, but it shouln't make a problem in URL.
When using the backslash I get:
And when removing both the slash and backslash:
I really dont understand what's wrong xD
Well, finally it works using simply this: ${sys.fullUrl(url.toString(),
catURL.toString())}
And also correcting my Xpath >.>
Thanks for your help :-)
Ah, the problem was in single qoutes. I just realised that. You should write
replace("some string",....).
It works like a charm.... thanks :)
No problem ;)