I have a pipeline that runs an XSLT on the input, then doing a PUT of that result into a database via a <p:http-request>
step.
The tricky bit here is that I need to build a dynamic href using metadata from the output of the <p:xslt>
XML.
Pseudo code here of what I'm trying to achieve:
<p:xslt name="XSLT1">
<p:input port="stylesheet">
<p:document href="XSLT-1.xslt" />
</p:input>
</p:xslt>
<p:variable name="href" select="concat('http://localhost:8000/myRESTendpoint?uri=/mydb/', /*/@name, /*/@number,'.xml')"/>
<p:sink />
<p:insert position="first-child" match="c:body">
<p:input port="source">
<p:inline>
<c:request
href="{$href}"
auth-method="basic"
username="user"
password="pw"
method="put">
<c:body content-type="text/xml" >
</c:body>
</c:request>
</p:inline>
</p:input>
<p:input port="insertion">
<p:pipe step="XSLT1" port="result" />
</p:input>
</p:insert>
<p:http-request omit-xml-declaration="false" encoding="UTF-8">
<p:input port="source"/>
</p:http-request>
As you can see in the <p:variable>
step, I'm trying to build a string and construct it with attribute values from the output XML of the <p:xslt>
step and feed that into my <c:request>
step's href option.
I've tried adding a <p:attribute match>
step to alter the href attribute before the <p:http-request>
but it doesn't grab the /*/@name
and /*/@number
values I need:
<p:add-attribute match="/c:request" attribute-name="href">
<p:with-option name="attribute-value" select="concat('http://localhost:8000/myRESTendpoint?uri=/mydb/', /*/@name, /*/@number,'.xml')"/>
</p:add-attribute>