- From: <vojtech.toman@emc.com>
- Date: Thu, 10 Mar 2011 03:09:56 -0500
- To: <xproc-dev@w3.org>
- Message-ID: <3799D0FD120AD940B731A37E36DAF3FE334C19B86B@MX20A.corp.emc.com>
You cannot use XPath in p:inline bindings. The content of p:inline is taken "as is", nothing is evaluated dynamically. You will have to use p:string-replace or p:template (see http://www.w3.org/TR/xproc-template/) to insert the iteration position in the "field" document
p:string-replace:
<p:for-each name="UploadInGroups">
<p:string-replace name="create-field" match="field/text()">
<p:input port="source">
<p:inline>
<field name="iterationCount">foo</field>
</p:inline>
</p:input>
<p:with-option name="replacement" select="concat("'", p:iteration-position(), "'")"/>
</p:template>
<p:insert position="last-child" match="/add/doc" name="insertCounter">
<p:input port="source">
<p:pipe step=" UploadInGroups" port="current"/>
</p:input>
<p:input port="insertion">
<p:pipe step="create-field" port="result"/>
</p:input>
</p:insert>
. . .
</p:for-each>
p:template:
<p:for-each name="UploadInGroups">
<p:template name="create-field">
<p:input port="template">
<p:inline>
<field name="iterationCount">$pos</field>
</p:inline>
</p:input>
<p:with-param name="pos" select="p:iteration-position()"/>
</p:template>
<p:insert position="last-child" match="/add/doc" name="insertCounter">
<p:input port="source">
<p:pipe step=" UploadInGroups" port="current"/>
</p:input>
<p:input port="insertion">
<p:pipe step="create-field" port="result"/>
</p:input>
</p:insert>
. . .
</p:for-each>
Generally, using p:template should be more intuitive and safer (no need to quote the replacement string as in the case of p:string-replace) to use.
Vojtech
--
Vojtech Toman
Consultant Software Engineer
EMC | Information Intelligence Group
vojtech.toman@emc.com
http://developer.emc.com/xmltech
From: xproc-dev-request@w3.org [mailto:xproc-dev-request@w3.org] On Behalf Of Christopher.R.Ball
Sent: Thursday, March 10, 2011 4:04 AM
To: XProc Dev
Subject: Dynamically setting the text of an added element in a pipeline . . ?
Am I missing something . . . or is it not possible to dynamically set the text() of an element in a pipeline (in xproc without having to jump out to P:XSTL or P:XQUERY)?
Something to the effect of:
<p:for-each name="UploadInGroups">
<p:insert position="last-child" match="/add/doc" name="insertCounter">
<p:input port="insertion">
<p:inline>
<field name="iterationCount">p:iteration-position()</field>
</p:inline>
</p:input>
</p:insert>
. . .
</p:for-each>
Most grateful,
Christopher
Received on Thursday, 10 March 2011 08:12:48 UTC