Orbeon XPL copy values from request

Quite often I end up in situations where I need to use a value from HTTP request (either parameter or header) inside a configuration element for another Orbeon XPL processor.

One fairly simple way to do this is to use oxf:xslt processor as shown below:

<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline">
	<!-- Read in request headers -->
	<p:processor name="oxf:request">
		<p:input name="config">
			<config>
				<include>/request/headers/username</include>				
			</config>
		</p:input>
		<p:output name="data" id="request" />
	</p:processor>

	<p:processor name="oxf:xslt">
		<p:input name="data" href="#request" />
		<p:input name="config">
			<config xsl:version="2.0">
				<orgUnit>A</orgUnit>
    			<username>
    				<xsl:value-of select="//header[name='username']/value"/>
    			</username>
			</config>
		</p:input>		
		<p:output name="data" id="config" />
	</p:processor>
</p:config>

The example code will take the “username” request header and combine it with the XML fragment:

<config>
	<orgUnit>A</orgUnit>
</config>

to create

<config>
	<orgUnit>A</orgUnit>
 	<username>...</username>
</config>

Another option could be to use the aggregate and xpointer functions.