Gary,
if i had a NodeIterator as the second argument after ExpressionContext , i
will also have to change the way the function is called , since otherwise
the argument values get disturbed.
-----Original Message-----
From: Gary L Peskin [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 23, 2001 12:49 PM
To: [EMAIL PROTECTED]
Subject: Re: Ext Func in XPath
Try having one of the functions take a
org.w3c.dom.traversal.NodeIterator as its second argument after the
ExpressionContext. This should get called for case 1. The one with the
two string arguments should get called for case 2. You can probably
just iterate through the nodes however you want and then call the case 2
function for each one.
Gary
Shruti Ahuja wrote:
>
> i need 2 versions of this function since there are 2 ways this function
can
> be invoked -
>
> 1. //book[txt:contains_words(./,"Trenton")]
> 2. txt:contains_words("This is a book","book")
>
> the first call results in searching an XML document . it searches for
> "Trenton" in the text of all book elements and returns all those book
> elements which have "Trenton" in their text.
>
> whereas the second one should return the string "true" or "false" by just
> searching the second string in the first string . It will search "book" in
> "This is a book", and should return "true" in this case.
>
> i was initially using just one function which was expecting an
> ExpressionContext in its argument , but i was getting an exception in
> callFunction() in ExtensionHandlerJavaClass.java in extensions folder.
> how do i overcome this problem ?
>
> -----Original Message-----
> From: Gary L Peskin [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 23, 2001 12:09 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Ext Func in XPath
>
> The method selection mechanism in Xalan will always prefer the second
> signature since signatures that begin with an ExpressionContext argument
> are preferred over those that don't. Why do you need these two
> functions with the same name? Do they do different things?
>
> Gary
>
> Shruti Ahuja wrote:
> >
> > > Hello
> > >
> > > i have made an extension function in Xpath by the name contains_words
> > > .This function has 2 overloaded versions
> > > public static boolean contains_words(String searchstr,String tosearch)
> > > {
> > > //code
> > > }
> > > and
> > > public static boolean contains_words(ExpressionContext mycontext,
String
> > > searchstr,String tosearch)
> > > {
> > > //code
> > > }
> > >
> > >
> > > i am calling this function in my xpath expression as
> > > txt:conatins_words("this is a book","book")
> > > where txt is a namespace which maps to this extension class.
> > > The problem is that this call always results in the second
> contains_words
> > > being invoked .i want the first one to be invoked.
> > > can someone suggest the reason for it to behave this way.
> > >
> > >
> > > thanx
> > > Shruti