thanks Gary ....
Now i am able to use the tokenize function but i am not getting the correct
output ...

my input xml looks like -

<employees xmlns:xalan="http://xml.apache.org/xalan";>
<employee>Herbert,Johnny,09/01/1998,95000</employee>
<employee>Hill,Graham,08/20/2000,89000</employee>
</employees>

and the xpath query is //employee[xalan:tokenize(./,",")]... i am evaluating
is query using

NodeIterator n1= XPathAPI.selectNodeIterator(doc, xpath) where xpath
contains the query string and doc is the document object.
but the resultant nodeset has the same output as the input ... the text is
not seperated on the basis of the token ....
can u suggest why ?



----- Original Message -----
From: Gary L Peskin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 11, 2001 12:49 AM
Subject: Re: Addition of a new function


> Yes, you can do this.  Declare the xalan namespace on the root node of
> your document, like this:
>
>   xmlns:xalan="http://xml.apache.org/xalan";
>
> Gary
>
> shruti wrote:
> >
> > Can i use this tokenize function in an XPath query ......
> > if yes, where do i register the xalan namespace in the evaluation
> > context....i am evaluating the xpath expression using
> >
> > XPathAPI.eval(doc,xpath);
> > If i give the following xpath expression
file://book[.=xalan:tokenize(hello ho)],
> > it  gives an error -
> >
> > Prefix must resolve to a namespace : xalan
> >
> > ----- Original Message -----
> > From: Gary L Peskin <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, July 04, 2001 11:23 PM
> > Subject: Re: Addition of a new function
> >
> > > Shruti --
> > >
> > > I think you'd be better off by implementing an XSLT extension function
> > > rather than changing the core of XalanJ.
> > >
> > > Have a look at http://xml.apache.org/xalan-j/extensions.html and at
the
> > > XSLT Recommendation itself.
> > >
> > > You'd also find some good examples in org.apache.xalan.lib.Extensions.
> > > It seems like you might be able to use the tokenize extension
> > > (http://xml.apache.org/xalan-j/extensionslib.html#tokenize), already
> > > supplied by XalanJ, to accomplish what you want:
> > >
> > >   file://book[. = xalan:tokenize("hello ho")]
> > >
> > > or something like that.
> > >
> > > Gary
> > >
> > > > shruti wrote:
> > > >
> > > > Hello,
> > > >
> > > > i have to add a new function to the xalan's xpath list of functions.
i
> > > > am adding a function for searching a list of words .
> > > > It would be an extension to the xalan's contains function ...
> > > >
> > > > file://book[contains(./,"hello")]
> > > > file://book[contains-words(./,"hello hi","any")] - this would search
for
> > > > words hello and hi and returns all the nodes which have either hello
> > > > or hi in their text.
> > > >
> > > > For this i had to add a class (FunctionContainsWords.java) in the
> > > > org/apache/xpath/functions package and make an appropriate entry for
> > > > this function in the function table and keywords class
> > > >
> > > > Could their be any alternative approach possible by which i could
add
> > > > this function by not changing the existing code . But by just
deriving
> > > > my own classes from the existing ones..
> > > >
> > > > Please suggest...
> > > >
> > > > thanx
> > > > Shruti.
> > > >
> > > >

Reply via email to