You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by "Mikkel R. Jakobsen" <mr...@interflow.dk> on 2002/09/02 13:18:39 UTC

Xindice's XPath implementation

Anyone know exactly what XPath functions that are implemented in Xindice? I
need an overview of string and number functions, both among the core
functions described in the XPath 1.0 specification and any additional
functions.

Specifically I want to use regular expressions in my XPath-expressions,
like:

/customer[regex(@name, '.* von .*')]

which returns all customer-elements that contains a name-attribute matching
the regular expression '.* von .*', f.ex. 'Herbert von Karajan'.


Regards,

Mikkel R. Jakobsen -- mrj@interflow.dk
Interflow -- http://www.interflow.dk


Re: Xindice's XPath implementation

Posted by "Mikkel R. Jakobsen" <mr...@interflow.dk>.
Thank you, Terry, for your thorough answer! I think changing the
XPathQueryImpl reaches somewhat above my level of ambitions, though I admit
that it would be nice to contribute something to the Xindice project.

Still, will I be able to find a condensed list of XPath functions
implemented in Xindice somewhere? Perhaps by probing through some source
files in the Xindice source - in that case, could someone please direct me
to a particular package or class perhaps in which to look for answers?


Kind regards,

Mikkel

----- Original Message -----
From: "Terry Rosenbaum" <Te...@amicas.com>
To: <xi...@xml.apache.org>
Cc: <mr...@interflow.dk>
Sent: Monday, September 02, 2002 5:58 PM
Subject: Re: Xindice's XPath implementation


> Mikkel Jakobsen wrote asking about the possibility
> of using regular expression matching in XPath queries
> in Xindice.
>
> In theory, using regular expressions should be possible
> by implementing extension functions. Look at
> the "PatternMatcher" ("Example 2: Regular Expressions") example at
> http://www-106.ibm.com/developerworks/library/x-callbk/?open&l=976,t=gr
> This example can be made to work using xalan doing XSLT
> transforms, but currently not when using XPath (i.e. not in Xindice).
>
> XIndice uses the org.apache.xpath.XPathContext class of xalan to
> run XPath queries. XPathContext requires that one supply an owner
> object in the ctor if one wishes to use extensions. That owner object
> must implement at least the org.apache.xpath.ExtensionsProvider interface.
> The XPathContext class also has a no-arg ctor that supplies a null owner
> object.
> Xindice uses the no-arg ctor. Thus, any attempts at using extension
> functions will result in null-pointer exception when the xpath code
> attempts to resolve the extension function. (see Apache bug 11792).
> (http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11792)
>
> If you wish to use extension functions, you'll need to modify
> org.apache.xindice.core.xupdate.XPathQueryImpl
> and org.apache.xindice.core.query.XPathQueryResolver classes to
> supply an ExtensionsProvider when doing "new XPathContext();".
>
> There are also namespace considerations. There must be a means of
> mapping the namespace prefixes for the extension functions. The
> prefixes could be resolved either from definitions in the source document,
> or in a separate document. XPathQueryImpl implements code to
> do it either way. XPathQueryResolver may require some work
> to resolve namespace prefixes from definitions contained in a
> separate document (I'm not sure -- you'ld need to carefully examine
> the code for XPathQueryResolver).
>
> For details on how to implement an ExtensionsProvider, look at
> org.apache.xalan.transformer.TransformerImpl code. That is the
> only currently-known implementer of the ExtensionsProvider interface.
>
> -Terry
>
> Mikkel R. Jakobsen wrote:
>
> >Anyone know exactly what XPath functions that are implemented in Xindice?
I
> >need an overview of string and number functions, both among the core
> >functions described in the XPath 1.0 specification and any additional
> >functions.
> >
> >Specifically I want to use regular expressions in my XPath-expressions,
> >like:
> >
> >/customer[regex(@name, '.* von .*')]
> >
> >which returns all customer-elements that contains a name-attribute
matching
> >the regular expression '.* von .*', f.ex. 'Herbert von Karajan'.
> >
> >
> >Regards,
> >
> >Mikkel R. Jakobsen -- mrj@interflow.dk
> >Interflow -- http://www.interflow.dk
> >
> >
> >
>
>
>


Re: Xindice's XPath implementation

Posted by Terry Rosenbaum <Te...@amicas.com>.
Mikkel Jakobsen wrote asking about the possibility
of using regular expression matching in XPath queries
in Xindice.

In theory, using regular expressions should be possible
by implementing extension functions. Look at
the "PatternMatcher" ("Example 2: Regular Expressions") example at
http://www-106.ibm.com/developerworks/library/x-callbk/?open&l=976,t=gr
This example can be made to work using xalan doing XSLT
transforms, but currently not when using XPath (i.e. not in Xindice).

XIndice uses the org.apache.xpath.XPathContext class of xalan to
run XPath queries. XPathContext requires that one supply an owner
object in the ctor if one wishes to use extensions. That owner object
must implement at least the org.apache.xpath.ExtensionsProvider interface.
The XPathContext class also has a no-arg ctor that supplies a null owner 
object.
Xindice uses the no-arg ctor. Thus, any attempts at using extension
functions will result in null-pointer exception when the xpath code
attempts to resolve the extension function. (see Apache bug 11792).
(http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11792)

If you wish to use extension functions, you'll need to modify
org.apache.xindice.core.xupdate.XPathQueryImpl
and org.apache.xindice.core.query.XPathQueryResolver classes to
supply an ExtensionsProvider when doing "new XPathContext();".

There are also namespace considerations. There must be a means of
mapping the namespace prefixes for the extension functions. The
prefixes could be resolved either from definitions in the source document,
or in a separate document. XPathQueryImpl implements code to
do it either way. XPathQueryResolver may require some work
to resolve namespace prefixes from definitions contained in a
separate document (I'm not sure -- you'ld need to carefully examine
the code for XPathQueryResolver).

For details on how to implement an ExtensionsProvider, look at
org.apache.xalan.transformer.TransformerImpl code. That is the
only currently-known implementer of the ExtensionsProvider interface.

-Terry

Mikkel R. Jakobsen wrote:

>Anyone know exactly what XPath functions that are implemented in Xindice? I
>need an overview of string and number functions, both among the core
>functions described in the XPath 1.0 specification and any additional
>functions.
>
>Specifically I want to use regular expressions in my XPath-expressions,
>like:
>
>/customer[regex(@name, '.* von .*')]
>
>which returns all customer-elements that contains a name-attribute matching
>the regular expression '.* von .*', f.ex. 'Herbert von Karajan'.
>
>
>Regards,
>
>Mikkel R. Jakobsen -- mrj@interflow.dk
>Interflow -- http://www.interflow.dk
>
>  
>



Re: Xindice's XPath implementation

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
This is not really an answer to your question, but in the particular query
below, you could use
   /customer[contains(@name,' von ')]
if regex is not available in xindice's XPath implementation.

Jeff

----- Original Message -----
From: "Mikkel R. Jakobsen" <mr...@interflow.dk>
To: <xi...@xml.apache.org>
Sent: Monday, September 02, 2002 4:18 AM
Subject: Xindice's XPath implementation


> Anyone know exactly what XPath functions that are implemented in Xindice?
I
> need an overview of string and number functions, both among the core
> functions described in the XPath 1.0 specification and any additional
> functions.
>
> Specifically I want to use regular expressions in my XPath-expressions,
> like:
>
> /customer[regex(@name, '.* von .*')]
>