Passing request parameters to model in an XSLT transformation

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

Passing request parameters to model in an XSLT transformation

Ethan Gruber
I have the following bit of code.  What I'd like to do is take two request parameters from the URL and pass them to the model, which is a service that generates XML based on the query parameters that I send it.

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <p:param type="output" name="data"/>

    <p:processor name="oxf:request">
        <p:input name="config">
            <config>
                <include>/request/parameters</include>
            </config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>
   
    <p:processor name="oxf:xslt">
        <p:input name="request" href="#request"/>
        <p:input name="data" href="<a href="http://localhost:8080/solr/published/select?q={}&amp;amp;start={}">http://localhost:8080/solr/published/select?q={}&amp;start={}"/>                       
        <p:input name="config" href="../xslt/results.xsl"/>
        <p:output name="data" ref="data"/>
    </p:processor>
</p:config>

My request parameters are 'q' and 'start.'  I tried the line         <p:input name="data" href="<a href="http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name=&#39;q&#39;]/value))}&amp;amp;start={#request#xpointer(string(/request/parameters/parameter[name=&#39;start&#39;]/value))}">http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name='q']/value))}&amp;start={#request#xpointer(string(/request/parameters/parameter[name='start']/value))}"/>, but I got a "can't parse ... in href" error in Orbeon.  Is it possible to pass request parameters in the way that I described?  Or perhaps there is another solution?

Thanks,
Ethan


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Passing request parameters to model in an XSLT transformation

bsteuhl
Ethan,
 
Do I understand that what you want to do is open up an Orbeon xForm with two parameters in the url, grab those parameters and send them to your service which will retrieve the xml and apply the stylesheet to present the xml back into the model for use within your xform?
 
If so, couldn't you just grab the parameters in the url when the form loads and place them in an instance within the model, call a submission (your service) which references that instance so you know have the two parameters available in your pipeline which you can access via xpath, configure an xsl processor which creates the input data href (your url string):
 
<p:processor name="oxf:xslt">
<p:input name="data" href="#instance">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
    <xsl:value-of select="concat('http://localhost:8080/solr/published/select?q=', /rootElement/q, '&amp;start=', /rootElement/start)" />
 
............
<p:output name="data" id="urlString" />
</p:processor>
 
 and then pass that output as the input for your current xslt processor.
 
<p:input name="data" href="#urlString" />
 
I have used this method for creating dynamic urls in the past with yahoo geocoding service.
 
If I misunderstood your design I apologize.  Made some assumptions.  Maybe this will help somehow.  Take care.
 

Brian Steuhl
website: http://BTMSoftwareSolutions.com
business email: [hidden email]
cell: 908-421-0742

home office: 732-961-3187
RSS Feed To My Blog:

Business Process Modeling - BTMSoftwareSolutions.com




From: Ethan Gruber <[hidden email]>
To: [hidden email]
Sent: Tue, August 3, 2010 10:45:22 AM
Subject: [ops-users] Passing request parameters to model in an XSLT transformation

I have the following bit of code.  What I'd like to do is take two request parameters from the URL and pass them to the model, which is a service that generates XML based on the query parameters that I send it.

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <p:param type="output" name="data"/>

    <p:processor name="oxf:request">
        <p:input name="config">
            <config>
                <include>/request/parameters</include>
            </config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>
   
    <p:processor name="oxf:xslt">
        <p:input name="request" href="#request"/>
        <p:input name="data" href="http://localhost:8080/solr/published/select?q={}&amp;start={}"/>                       
        <p:input name="config" href="../xslt/results.xsl"/>
        <p:output name="data" ref="data"/>
    </p:processor>
</p:config>

My request parameters are 'q' and 'start.'  I tried the line         <p:input name="data" href="http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name='q']/value))}&amp;start={#request#xpointer(string(/request/parameters/parameter[name='start']/value))}"/>, but I got a "can't parse ... in href" error in Orbeon.  Is it possible to pass request parameters in the way that I described?  Or perhaps there is another solution?

Thanks,
Ethan



--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Passing request parameters to model in an XSLT transformation

Ethan Gruber
Thanks, Brian.

I was thinking and I may have come up with a potential solution.  One thing I forgot to mention is that there isn't an XForm involved in this.  I'm just using the page flow/xpl to do an XML transformation, but the XML model in this case is generated by passing a few query parameters.  But I think concatenating the service URL and the request parameters is on the right track.  I believe I can then use the document() function in xsl to grab that XML and apply templates on it.

Ethan

On Tue, Aug 3, 2010 at 11:15 AM, Brian Steuhl <[hidden email]> wrote:
Ethan,
 
Do I understand that what you want to do is open up an Orbeon xForm with two parameters in the url, grab those parameters and send them to your service which will retrieve the xml and apply the stylesheet to present the xml back into the model for use within your xform?
 
If so, couldn't you just grab the parameters in the url when the form loads and place them in an instance within the model, call a submission (your service) which references that instance so you know have the two parameters available in your pipeline which you can access via xpath, configure an xsl processor which creates the input data href (your url string):
 
<p:processor name="oxf:xslt">
<p:input name="data" href="#instance">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
    <xsl:value-of select="concat('http://localhost:8080/solr/published/select?q=', /rootElement/q, '&amp;start=', /rootElement/start)" />
 
............
<p:output name="data" id="urlString" />
</p:processor>
 
 and then pass that output as the input for your current xslt processor.
 
<p:input name="data" href="#urlString" />
 
I have used this method for creating dynamic urls in the past with yahoo geocoding service.
 
If I misunderstood your design I apologize.  Made some assumptions.  Maybe this will help somehow.  Take care.
 

Brian Steuhl
website: http://BTMSoftwareSolutions.com
business email: [hidden email]
cell: 908-421-0742

home office: 732-961-3187
RSS Feed To My Blog:

Business Process Modeling - BTMSoftwareSolutions.com




From: Ethan Gruber <[hidden email]>
To: [hidden email]
Sent: Tue, August 3, 2010 10:45:22 AM
Subject: [ops-users] Passing request parameters to model in an XSLT transformation

I have the following bit of code.  What I'd like to do is take two request parameters from the URL and pass them to the model, which is a service that generates XML based on the query parameters that I send it.

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
    xmlns:oxf="http://www.orbeon.com/oxf/processors">

    <p:param type="output" name="data"/>

    <p:processor name="oxf:request">
        <p:input name="config">
            <config>
                <include>/request/parameters</include>
            </config>
        </p:input>
        <p:output name="data" id="request"/>
    </p:processor>
   
    <p:processor name="oxf:xslt">
        <p:input name="request" href="#request"/>
        <p:input name="data" href="http://localhost:8080/solr/published/select?q={}&amp;start={}"/>                       
        <p:input name="config" href="../xslt/results.xsl"/>
        <p:output name="data" ref="data"/>
    </p:processor>
</p:config>

My request parameters are 'q' and 'start.'  I tried the line         <p:input name="data" href="http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name='q']/value))}&amp;start={#request#xpointer(string(/request/parameters/parameter[name='start']/value))}"/>, but I got a "can't parse ... in href" error in Orbeon.  Is it possible to pass request parameters in the way that I described?  Or perhaps there is another solution?

Thanks,
Ethan



--
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
OW2 mailing lists service home page: http://www.ow2.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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Passing request parameters to model in an XSLT transformation

Alessandro  Vernet
Administrator
In reply to this post by Ethan Gruber
Ethan,

XPL doesn't support AVTs in the href attribute. You could use an XPath
expression in #xpointer that builds the URL with concat(), but when
using #xpointer, the result of the evaluation of the XPath expression
(typically an element) is fed to the processor as-is. If the processor
supports it, that XPath expression could return just a string, but
that string would be fed to the processor through SAX; it wouldn't be
interpreted as a URL.

So here, what you want to do is use the URL generator to retrieve the
document, using XSLT to build the configuration for the URL generator.
(And if you want to do more than an HTTP GET, you can use the XForms
submission processor, but based on your example, it doesn't seem that
this is the case here.)

Also, if that XPL is called directly from the page flow, as an
alternative to using the Request generator, you can use the page flow
to extract URL parameters into a document.

Alex

On Tuesday, August 3, 2010, Ethan Gruber <[hidden email]> wrote:

> I have the following bit of code.  What I'd like to do is take two request parameters from the URL and pass them to the model, which is a service that generates XML based on the query parameters that I send it.
>
> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
>     xmlns:oxf="http://www.orbeon.com/oxf/processors">
>
>     <p:param type="output" name="data"/>
>
>     <p:processor name="oxf:request">
>         <p:input name="config">
>             <config>
>                 <include>/request/parameters</include>
>             </config>
>         </p:input>
>         <p:output name="data" id="request"/>
>     </p:processor>
>
>     <p:processor name="oxf:xslt">
>         <p:input name="request" href="#request"/>
>         <p:input name="data" href="http://localhost:8080/solr/published/select?q={}&amp;start={}"/>
>         <p:input name="config" href="../xslt/results.xsl"/>
>         <p:output name="data" ref="data"/>
>     </p:processor>
> </p:config>
>
> My request parameters are 'q' and 'start.'  I tried the line         <p:input name="data" href="http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name='q']/value))}&amp;start={#request#xpointer(string(/request/parameters/parameter[name='start']/value))}"/>, but I got a "can't parse ... in href" error in Orbeon.  Is it possible to pass request parameters in the way that I described?  Or perhaps there is another solution?
>
> Thanks,
> Ethan
>
--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Passing request parameters to model in an XSLT transformation

Alessandro  Vernet
Administrator
In reply to this post by Ethan Gruber
Ethan,

XPL doesn't support AVTs in the href attribute. You could use an XPath
expression in #xpointer that builds the URL with concat(), but when
using #xpointer, the result of the evaluation of the XPath expression
(typically an element) is fed to the processor as-is. If the processor
supports it, that XPath expression could return just a string, but
that string would be fed to the processor through SAX; it wouldn't be
interpreted as a URL.

So here, what you want to do is use the URL generator to retrieve the
document, using XSLT to build the configuration for the URL generator.
(And if you want to do more than an HTTP GET, you can use the XForms
submission processor, but based on your example, it doesn't seem that
this is the case here.)

Also, if that XPL is called directly from the page flow, as an
alternative to using the Request generator, you can use the page flow
to extract URL parameters into a document.

Alex

On Tuesday, August 3, 2010, Ethan Gruber <[hidden email]> wrote:

> I have the following bit of code.  What I'd like to do is take two request parameters from the URL and pass them to the model, which is a service that generates XML based on the query parameters that I send it.
>
> <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline"
>     xmlns:oxf="http://www.orbeon.com/oxf/processors">
>
>     <p:param type="output" name="data"/>
>
>     <p:processor name="oxf:request">
>         <p:input name="config">
>             <config>
>                 <include>/request/parameters</include>
>             </config>
>         </p:input>
>         <p:output name="data" id="request"/>
>     </p:processor>
>
>     <p:processor name="oxf:xslt">
>         <p:input name="request" href="#request"/>
>         <p:input name="data" href="http://localhost:8080/solr/published/select?q={}&amp;start={}"/>
>         <p:input name="config" href="../xslt/results.xsl"/>
>         <p:output name="data" ref="data"/>
>     </p:processor>
> </p:config>
>
> My request parameters are 'q' and 'start.'  I tried the line         <p:input name="data" href="http://localhost:8080/solr/published/select?q={#request#xpointer(string(/request/parameters/parameter[name='q']/value))}&amp;start={#request#xpointer(string(/request/parameters/parameter[name='start']/value))}"/>, but I got a "can't parse ... in href" error in Orbeon.  Is it possible to pass request parameters in the way that I described?  Or perhaps there is another solution?
>
> Thanks,
> Ethan
>
--
Orbeon Forms - Web forms, open-source, for the Enterprise -
http://www.orbeon.com/
My Twitter: http://twitter.com/avernet


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet