- From: Norman Walsh <ndw@nwalsh.com>
- Date: Thu, 24 May 2007 10:31:35 -0400
- To: public-xml-processing-model-wg@w3.org
- Message-ID: <87k5uyfg3c.fsf@nwalsh.com>
/ ht@inf.ed.ac.uk (Henry S. Thompson) was heard to say: | Norman Walsh writes: | |> Whether we spell "position()" with or without a "p:" prefix, do we |> agree that the following pipeline |> |> <p:pipeline xmlns:p="http://www.w3.org/2007/03/xproc" |> name="pipeline"> |> |> <p:output port="result"/> |> |> <p:for-each> |> <p:iteration-source> |> <p:inline><doc v="test" s="test">one</doc></p:inline> |> <p:inline><doc v="test" s="test">two</doc></p:inline> |> <p:inline><doc v="test" s="test">three</doc></p:inline> |> <p:inline><doc v="test" s="test">four</doc></p:inline> |> </p:iteration-source> |> <p:output port="result"/> |> |> <p:string-replace> |> <p:option name="match" value="doc/@v"/> |> <p:option name="replace" value="p:position()"/> <!-- NB: value= --> |> </p:string-replace> |> |> <p:string-replace> |> <p:option name="match" value="doc/@s"/> |> <p:option name="replace" select="p:position()"/> <!-- NB: select= --> |> </p:string-replace> |> </p:for-each> |> |> </p:pipeline> |> |> produces |> |> <doc v="1" s="1">one</doc> |> <doc v="1" s="2">two</doc> |> <doc v="1" s="3">three</doc> |> <doc v="1" s="4">four</doc> |> |> That is, the position function evaluated in the context of the |> for-each counts the iterations through the sequence, but the position |> function evaluated in the context of the inputs passed to the |> string-replace function only ever sees one document because it doesn't |> receive a sequence. | | I don't see why these should be different. My original proposal was | that in the context of an iteration, p:position would always tell you | what the position of the document being processed in the subpipeline | is -- why should that be different in at the margin of the component, | or inside it? Do we agree that *outside* the context of a for-each, if the input to this step is a sequence of three documents: <p:matching-documents> <p:option name="test" value="p:position() mod 2 = 1"/> <!-- NB: value= --> </p:string-replace> then the p:position() function will return "1" for the first document, "2" for the second document, and "3" for the third document in the sequence? If so, then *inside* the context of a for-each, where the input to this step is a single document (from the 'current' port): <p:matching-documents> <p:option name="test" value="p:position() mod 2 = 1"/> <!-- NB: value= --> </p:string-replace> the p:position() function must return 1 for the first (and only) document that matching-documents step sees on its input port. Anything else would seem wildly inconsistent. However, if you arrange to have p:position() evaluated before being passed to the step, i.e., if you use select= instead of value=, then p:position() is evaluated in the context of the for-each where the natural thing to do is count the number of documents that have passed by. Be seeing you, norm -- Norman Walsh <ndw@nwalsh.com> | If a little knowledge is dangerous, http://nwalsh.com/ | where is the man who has so much as to | be out of danger?--Thomas. H. Huxley
Received on Thursday, 24 May 2007 14:32:14 UTC