Cannot execute xxforms:get-request-parameter in XPL - XSLT processor
سؤال
I get the error:
XPath syntax error at ... in {...get-request-parameter('query..}:
Cannot find a matching 1-argument function named {http://orbeon.org/oxf/xml/xforms}get-request-parameter(). Note: external function calls have been disabled
when I attempt to execute a pipeline with:
<p:processor name="oxf:xslt">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<TargetURL>
<xsl:variable name="location" select="/Configuration/XMLDB/Location/text()"/>
<xsl:variable name="name" select="/Configuration/XMLDB/Name/text()"/>
<xsl:variable name="query" select="xxforms:get-request-parameter('query')"/>
<xsl:value-of select="fn:concat($location,'/',$name,'?',$query)"/>
</TargetURL>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:input name="data" href="#configuration"/>
<p:output name="data" id="Target"/>
</p:processor>
Is XPL not the correct location to retrieve the HTTP request params (should I be doing it in page-flow.xml instead?)
المحلول
Solved it by using the oxf:request processor in the XPL to retrieve query parameters and provide them on a separate output which is then accessed using oxf:xslt processor, like so:
<p:processor name="oxf:request">
<p:input name="config">
<config>
<include>/request/parameters/parameter[name='param1']</include>
<include>/request/parameters/parameter[name='param2']</include>
</config>
</p:input>
<p:output name="data" id="request"/>
</p:processor>
<p:processor name="oxf:xslt">
<p:input name="config">
<xsl:stylesheet version="2.0">
<xsl:template match="/">
<TargetURL>
<xsl:variable name="var1" select="doc('input:request')/request/parameters/parameter[name='param1']/value"/>
<xsl:variable name="var2" select="doc('input:request')/request/parameters/parameter[name='param2']/value"/>
</TargetURL>
</xsl:template>
</xsl:stylesheet>
</p:input>
<p:input name="data" href="#configuration"/>
<p:input name="request" href="#request"/>
<p:output name="data" id="Target"/>
</p:processor>
نصائح أخرى
xxforms:get-request-parameter()
is designed to called from XForms, but you are here calling it from XSLT.
Do you really need to use XPL/XSLT in this case? In most cases, if what you are generating is a web page, you might just be able to use XForms. In your page flow, you point to your XForms with the view
attribute, and in your XForms, on xforms-model-construct-done
, you can access the request parameters with xxforms:get-request-parameter()
, and copy their value somewhere in an instance if necessary.