Dynamic XPath support?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic XPath support?

Duane Gran
First off, many thanks for the advice offered on the list concerning  
my previous message (Manipulating the order of elements).  I have a  
prototype working very well, using XUpdate with some hard-coded  
values, but I'm running into what I believe is a common frustration  
with XPath -- the lack of dynamic xpath expressions.  Let me show an  
example of my input document:

<form>
     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
     <document>
         <mods>
             <titleInfo>
                 <title>Sound and fury</title>
                 <subTitle>my sub title</subTitle>
             </titleInfo>
          </mods>
     </document>
</form>

I'm trying to create an XUpdate variable ($sub) which uses the data  
found in /form/xpath.  I'm trying the following without success:

<xu:variable name="path-to-node" select="/form/xpath"/>
<xu:variable name="sub" select="$path-to-node"/>

I've also tried select="/form/xpath/text()" with no luck -- all  
xu:remove and xu:insert* commands fail silently.  I found the  
following third-party effort to support dynamic XPath, which has an  
evaluate() method to address this issue:

   http://www.exslt.org/dyn/index.html

I believe Saxon has an evaluate() method as well.  My question is  
whether OPS has any support for this feature?  When I try to use the  
evalute() function I get an exception stating "Unsupported type:  
org.jaxen.function.ext.EvaluateFunction".

Duane Gran



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

RE: Dynamic XPath support?

Ryan Puddephatt
Duane,
        I'm pretty sure OPS supports all the saxon functions, you will need
to call saxon:evaluate(), not sure of the saxon namespace, but I'm sure it
will be on the ops or saxon website

Ryan Puddephatt
Web Developer
TFX Group
1 Michaelson Square
Livingston
West Lothian
Scotand
EH54 7DP
 
* [hidden email]
( 01506 407 110
7  01506 407 108
 

>-----Original Message-----
>From: Duane Gran [mailto:[hidden email]]
>Sent: 02 January 2006 02:23
>To: [hidden email]
>Subject: [ops-users] Dynamic XPath support?
>
>First off, many thanks for the advice offered on the list concerning
>my previous message (Manipulating the order of elements).  I have a
>prototype working very well, using XUpdate with some hard-coded
>values, but I'm running into what I believe is a common frustration
>with XPath -- the lack of dynamic xpath expressions.  Let me show an
>example of my input document:
>
><form>
>     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
>     <document>
>         <mods>
>             <titleInfo>
>                 <title>Sound and fury</title>
>                 <subTitle>my sub title</subTitle>
>             </titleInfo>
>          </mods>
>     </document>
></form>
>
>I'm trying to create an XUpdate variable ($sub) which uses the data
>found in /form/xpath.  I'm trying the following without success:
>
><xu:variable name="path-to-node" select="/form/xpath"/>
><xu:variable name="sub" select="$path-to-node"/>
>
>I've also tried select="/form/xpath/text()" with no luck -- all
>xu:remove and xu:insert* commands fail silently.  I found the
>following third-party effort to support dynamic XPath, which has an
>evaluate() method to address this issue:
>
>   http://www.exslt.org/dyn/index.html
>
>I believe Saxon has an evaluate() method as well.  My question is
>whether OPS has any support for this feature?  When I try to use the
>evalute() function I get an exception stating "Unsupported type:
>org.jaxen.function.ext.EvaluateFunction".
>
>Duane Gran




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic XPath support?

Erik Bruchez
Administrator
In reply to this post by Duane Gran
Duane,

With Saxon, you can use saxon:evaluate(). With EXSLT, dyn:evaluate().
Both should work with Saxon, and dyn:evaluate() should work with pretty
much any XSLT processor out there that implements EXSLT extensions,
including Saxon and Xalan. Don't forget to map the "saxon" or "dyn"
namespaces correctly.

The XUpdate processor uses Jaxen to perform XPath evaluations. I believe
that Jaxen supports the dyn:evaluate() function, so you may want to give
this a try (obviously saxon:evaluate() will not work in this case). If
that doesn't work, you could use an additional step with XSLT to
evaluate the XPath expression.

-Erik

Duane Gran wrote:

> First off, many thanks for the advice offered on the list concerning  my
> previous message (Manipulating the order of elements).  I have a  
> prototype working very well, using XUpdate with some hard-coded  values,
> but I'm running into what I believe is a common frustration  with XPath
> -- the lack of dynamic xpath expressions.  Let me show an  example of my
> input document:
>
> <form>
>     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
>     <document>
>         <mods>
>             <titleInfo>
>                 <title>Sound and fury</title>
>                 <subTitle>my sub title</subTitle>
>             </titleInfo>
>          </mods>
>     </document>
> </form>
>
> I'm trying to create an XUpdate variable ($sub) which uses the data  
> found in /form/xpath.  I'm trying the following without success:
>
> <xu:variable name="path-to-node" select="/form/xpath"/>
> <xu:variable name="sub" select="$path-to-node"/>
>
> I've also tried select="/form/xpath/text()" with no luck -- all  
> xu:remove and xu:insert* commands fail silently.  I found the  following
> third-party effort to support dynamic XPath, which has an  evaluate()
> method to address this issue:
>
>   http://www.exslt.org/dyn/index.html
>
> I believe Saxon has an evaluate() method as well.  My question is  
> whether OPS has any support for this feature?  When I try to use the  
> evalute() function I get an exception stating "Unsupported type:  
> org.jaxen.function.ext.EvaluateFunction".
>
> Duane Gran


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic XPath support?

Duane Gran
Erik,

Thanks for the pointer.  I added the namespace (xmlns:dyn="http://
exslt.org/dynamic") and when issuing a call to dyn:evaluate(/my/
xpath) OPS throws a Jaxen exeption.  Below is a snippet:

org.jaxen.UnresolvableException: Function dyn:evaluate
         at org.jaxen.SimpleFunctionContext.getFunction
(SimpleFunctionContext.java:142)
         at org.orbeon.oxf.transformer.xupdate.statement.Utils$5.call
(Utils.java:149)

This implies to me that Jaxen isn't configured to handle EXSLT  
functions.  I found the following explanation for how to set it up on  
the Java side:

   http://jaxen.org/extensions.html

Before I dig into the cvs to try this out myself (and contribute it  
back, if desired) do you think I'm correct in my assessment of the  
situation?  Also, I sense some negative tone about using XUpdate.  
Would I be wiser to move the nodes with XSLT?

Duane

On Jan 2, 2006, at 4:54 PM, Erik Bruchez wrote:

> Duane,
>
> With Saxon, you can use saxon:evaluate(). With EXSLT, dyn:evaluate
> (). Both should work with Saxon, and dyn:evaluate() should work  
> with pretty much any XSLT processor out there that implements EXSLT  
> extensions, including Saxon and Xalan. Don't forget to map the  
> "saxon" or "dyn" namespaces correctly.
>
> The XUpdate processor uses Jaxen to perform XPath evaluations. I  
> believe that Jaxen supports the dyn:evaluate() function, so you may  
> want to give this a try (obviously saxon:evaluate() will not work  
> in this case). If that doesn't work, you could use an additional  
> step with XSLT to evaluate the XPath expression.
>
> -Erik
>
> Duane Gran wrote:
>> First off, many thanks for the advice offered on the list  
>> concerning  my previous message (Manipulating the order of  
>> elements).  I have a  prototype working very well, using XUpdate  
>> with some hard-coded  values, but I'm running into what I believe  
>> is a common frustration  with XPath -- the lack of dynamic xpath  
>> expressions.  Let me show an  example of my input document:
>> <form>
>>     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
>>     <document>
>>         <mods>
>>             <titleInfo>
>>                 <title>Sound and fury</title>
>>                 <subTitle>my sub title</subTitle>
>>             </titleInfo>
>>          </mods>
>>     </document>
>> </form>
>> I'm trying to create an XUpdate variable ($sub) which uses the  
>> data  found in /form/xpath.  I'm trying the following without  
>> success:
>> <xu:variable name="path-to-node" select="/form/xpath"/>
>> <xu:variable name="sub" select="$path-to-node"/>
>> I've also tried select="/form/xpath/text()" with no luck -- all  
>> xu:remove and xu:insert* commands fail silently.  I found the  
>> following third-party effort to support dynamic XPath, which has  
>> an  evaluate() method to address this issue:
>>   http://www.exslt.org/dyn/index.html
>> I believe Saxon has an evaluate() method as well.  My question is  
>> whether OPS has any support for this feature?  When I try to use  
>> the  evalute() function I get an exception stating "Unsupported  
>> type:  org.jaxen.function.ext.EvaluateFunction".
>> Duane Gran
>
>
> --
> You receive this message as a subscriber of the ops-
> [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/ 
> wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic XPath support?

Erik Bruchez
Administrator
Duane,

I guess the "dyn:evaluate" function is not hooked up by default. FWIW,
the XUpdate processor uses Dom4jUtils.createXPath() to create XPath
expressions, which is not the "modern" to do this in OPS anymore.

However I found out that we do hook-up a proprietery "evaluate" function
in the XUpdate processor, called simply "evaluate". It takes three
arguments:

1. The XPath expression to evaluate (string)
2. A list of namespaces in scope (namespace nodes)
3. A context node (node)

Example:

<xu:value-of select="evaluate('123',
     /*/my-context-node/namespace::*,
     /*/my-context-node)"/>

You can give this a try.

-Erik

Duane Gran wrote:

> Erik,
>
> Thanks for the pointer.  I added the namespace (xmlns:dyn="http://
> exslt.org/dynamic") and when issuing a call to dyn:evaluate(/my/ xpath)
> OPS throws a Jaxen exeption.  Below is a snippet:
>
> org.jaxen.UnresolvableException: Function dyn:evaluate
>         at org.jaxen.SimpleFunctionContext.getFunction
> (SimpleFunctionContext.java:142)
>         at org.orbeon.oxf.transformer.xupdate.statement.Utils$5.call
> (Utils.java:149)
>
> This implies to me that Jaxen isn't configured to handle EXSLT  
> functions.  I found the following explanation for how to set it up on  
> the Java side:
>
>   http://jaxen.org/extensions.html
>
> Before I dig into the cvs to try this out myself (and contribute it  
> back, if desired) do you think I'm correct in my assessment of the  
> situation?  Also, I sense some negative tone about using XUpdate.  
> Would I be wiser to move the nodes with XSLT?
>
> Duane
>
> On Jan 2, 2006, at 4:54 PM, Erik Bruchez wrote:
>
>> Duane,
>>
>> With Saxon, you can use saxon:evaluate(). With EXSLT, dyn:evaluate ().
>> Both should work with Saxon, and dyn:evaluate() should work  with
>> pretty much any XSLT processor out there that implements EXSLT  
>> extensions, including Saxon and Xalan. Don't forget to map the  
>> "saxon" or "dyn" namespaces correctly.
>>
>> The XUpdate processor uses Jaxen to perform XPath evaluations. I  
>> believe that Jaxen supports the dyn:evaluate() function, so you may  
>> want to give this a try (obviously saxon:evaluate() will not work  in
>> this case). If that doesn't work, you could use an additional  step
>> with XSLT to evaluate the XPath expression.
>>
>> -Erik
>>
>> Duane Gran wrote:
>>
>>> First off, many thanks for the advice offered on the list  
>>> concerning  my previous message (Manipulating the order of  
>>> elements).  I have a  prototype working very well, using XUpdate  
>>> with some hard-coded  values, but I'm running into what I believe  is
>>> a common frustration  with XPath -- the lack of dynamic xpath  
>>> expressions.  Let me show an  example of my input document:
>>> <form>
>>>     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
>>>     <document>
>>>         <mods>
>>>             <titleInfo>
>>>                 <title>Sound and fury</title>
>>>                 <subTitle>my sub title</subTitle>
>>>             </titleInfo>
>>>          </mods>
>>>     </document>
>>> </form>
>>> I'm trying to create an XUpdate variable ($sub) which uses the  data  
>>> found in /form/xpath.  I'm trying the following without  success:
>>> <xu:variable name="path-to-node" select="/form/xpath"/>
>>> <xu:variable name="sub" select="$path-to-node"/>
>>> I've also tried select="/form/xpath/text()" with no luck -- all  
>>> xu:remove and xu:insert* commands fail silently.  I found the  
>>> following third-party effort to support dynamic XPath, which has  an  
>>> evaluate() method to address this issue:
>>>   http://www.exslt.org/dyn/index.html
>>> I believe Saxon has an evaluate() method as well.  My question is  
>>> whether OPS has any support for this feature?  When I try to use  
>>> the  evalute() function I get an exception stating "Unsupported  
>>> type:  org.jaxen.function.ext.EvaluateFunction".
>>> Duane Gran


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Dynamic XPath support?

Alessandro  Vernet
Administrator
The evaluate() extension function available in XPath evaluated by the
XUpdate processor is now documented:

http://www.orbeon.com/ops/doc/processors-xupdate#xpath

Alex

On 1/3/06, Erik Bruchez <[hidden email]> wrote:

> Duane,
>
> I guess the "dyn:evaluate" function is not hooked up by default. FWIW,
> the XUpdate processor uses Dom4jUtils.createXPath() to create XPath
> expressions, which is not the "modern" to do this in OPS anymore.
>
> However I found out that we do hook-up a proprietery "evaluate" function
> in the XUpdate processor, called simply "evaluate". It takes three
> arguments:
>
> 1. The XPath expression to evaluate (string)
> 2. A list of namespaces in scope (namespace nodes)
> 3. A context node (node)
>
> Example:
>
> <xu:value-of select="evaluate('123',
>      /*/my-context-node/namespace::*,
>      /*/my-context-node)"/>
>
> You can give this a try.
>
> -Erik
>
> Duane Gran wrote:
> > Erik,
> >
> > Thanks for the pointer.  I added the namespace (xmlns:dyn="http://
> > exslt.org/dynamic") and when issuing a call to dyn:evaluate(/my/ xpath)
> > OPS throws a Jaxen exeption.  Below is a snippet:
> >
> > org.jaxen.UnresolvableException: Function dyn:evaluate
> >         at org.jaxen.SimpleFunctionContext.getFunction
> > (SimpleFunctionContext.java:142)
> >         at org.orbeon.oxf.transformer.xupdate.statement.Utils$5.call
> > (Utils.java:149)
> >
> > This implies to me that Jaxen isn't configured to handle EXSLT
> > functions.  I found the following explanation for how to set it up on
> > the Java side:
> >
> >   http://jaxen.org/extensions.html
> >
> > Before I dig into the cvs to try this out myself (and contribute it
> > back, if desired) do you think I'm correct in my assessment of the
> > situation?  Also, I sense some negative tone about using XUpdate.
> > Would I be wiser to move the nodes with XSLT?
> >
> > Duane
> >
> > On Jan 2, 2006, at 4:54 PM, Erik Bruchez wrote:
> >
> >> Duane,
> >>
> >> With Saxon, you can use saxon:evaluate(). With EXSLT, dyn:evaluate ().
> >> Both should work with Saxon, and dyn:evaluate() should work  with
> >> pretty much any XSLT processor out there that implements EXSLT
> >> extensions, including Saxon and Xalan. Don't forget to map the
> >> "saxon" or "dyn" namespaces correctly.
> >>
> >> The XUpdate processor uses Jaxen to perform XPath evaluations. I
> >> believe that Jaxen supports the dyn:evaluate() function, so you may
> >> want to give this a try (obviously saxon:evaluate() will not work  in
> >> this case). If that doesn't work, you could use an additional  step
> >> with XSLT to evaluate the XPath expression.
> >>
> >> -Erik
> >>
> >> Duane Gran wrote:
> >>
> >>> First off, many thanks for the advice offered on the list
> >>> concerning  my previous message (Manipulating the order of
> >>> elements).  I have a  prototype working very well, using XUpdate
> >>> with some hard-coded  values, but I'm running into what I believe  is
> >>> a common frustration  with XPath -- the lack of dynamic xpath
> >>> expressions.  Let me show an  example of my input document:
> >>> <form>
> >>>     <xpath>/form/document/mods/titleInfo/subTitle</xpath>
> >>>     <document>
> >>>         <mods>
> >>>             <titleInfo>
> >>>                 <title>Sound and fury</title>
> >>>                 <subTitle>my sub title</subTitle>
> >>>             </titleInfo>
> >>>          </mods>
> >>>     </document>
> >>> </form>
> >>> I'm trying to create an XUpdate variable ($sub) which uses the  data
> >>> found in /form/xpath.  I'm trying the following without  success:
> >>> <xu:variable name="path-to-node" select="/form/xpath"/>
> >>> <xu:variable name="sub" select="$path-to-node"/>
> >>> I've also tried select="/form/xpath/text()" with no luck -- all
> >>> xu:remove and xu:insert* commands fail silently.  I found the
> >>> following third-party effort to support dynamic XPath, which has  an
> >>> evaluate() method to address this issue:
> >>>   http://www.exslt.org/dyn/index.html
> >>> I believe Saxon has an evaluate() method as well.  My question is
> >>> whether OPS has any support for this feature?  When I try to use
> >>> the  evalute() function I get an exception stating "Unsupported
> >>> type:  org.jaxen.function.ext.EvaluateFunction".
> >>> Duane Gran
>
>
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>
>

--
Blog (XML, Web apps, Open Source): http://www.orbeon.com/blog/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet