I'm intrigued by the potential usage of mypackage.MyXmlLibrary
in the example given on the Usage page. Can anyone point me to
(or offer?) any guidance on the usage?
cheers, Cal
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Cool maybe, but I'm struggling with it. A straight object passes back and forth just fine, but trying to use anything with a method fails -
Exception in thread "main" org.webharvest.exception.TemplaterException:
Error evaluating expression: myXmlLib.append( groupurl )
at org.webharvest.runtime.templaters.BaseTemplater.execute(Unknown Source)
...
Caused by: ognl.MethodFailedException: Method "append" failed for object
MyXmlLibrary@140c281 [java.lang.NoSuchMethodException:
append(org.webharvest.runtime.variables.NodeVariable)]
That's with a very simple class -
public class MyXmlLibrary {
public void append( NodeVariable x ) {
// do whatever you want
}
}
Any suggestions are most welcome.
cheers, Cal
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Putting the variable into the scraper context is fine, but in terms of "It worked for me", how do you go when you try to use a XXXX.method in your config? That's where I was having trouble.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm intrigued by the potential usage of mypackage.MyXmlLibrary
in the example given on the Usage page. Can anyone point me to
(or offer?) any guidance on the usage?
cheers, Cal
That is the way to extend expressing power of Web-Harvest.
mypackage.MyXmlLibrary is just example name for some user-defined class.
The line:
adds new variable - instance of class MyXmlLibrary to the web-harvest's context.
After that you may use it in your configuration, for example:
This example applies custom logic on each element of the list.
very cool, thank you!
Cool maybe, but I'm struggling with it. A straight object passes back and forth just fine, but trying to use anything with a method fails -
Exception in thread "main" org.webharvest.exception.TemplaterException:
Error evaluating expression: myXmlLib.append( groupurl )
at org.webharvest.runtime.templaters.BaseTemplater.execute(Unknown Source)
...
Caused by: ognl.MethodFailedException: Method "append" failed for object
MyXmlLibrary@140c281 [java.lang.NoSuchMethodException:
append(org.webharvest.runtime.variables.NodeVariable)]
That's with a very simple class -
public class MyXmlLibrary {
public void append( NodeVariable x ) {
// do whatever you want
}
}
Any suggestions are most welcome.
cheers, Cal
Hi Cal,
try this:
scraper.getContext().put("celi",new XXXX());
It worked for me.
Bests,
Luca
Putting the variable into the scraper context is fine, but in terms of "It worked for me", how do you go when you try to use a XXXX.method in your config? That's where I was having trouble.