Re: p:exec -- can it apply to only selected parts of input using a loop?

Sorry if I was a bit annoying on this posting but I found the discussion
instructive and the emotion I was trying to convey from the keyboard was one
of positive inquisitive criticism. I had some more thoughts on this which
led to some observations.

Jostein opened my eyes to the fact that viewport is more a for-each-match
than a modify nodes.

The thought came to mind that this common xslt pattern could be thought of
as a viewport in some way.

<xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

<xsl:template match="some/path">
  ...
</xsl:template>


I studied more about the difference between for-each and viewport in the
spec.

I noted from the spec that one important difference is that for-each can
apply to a "sequence of documents" and viewport applies to a "single
document" both "applying its subpipeline to one or more subtrees".

I had not yet seen an example applying for-each to a sequence of documents
as it's input but would like to see one. Rather the examples I have seen are
all applying a for-each to one input document like a directory list and say
outputting a sequence of documents.


I note the spec says when describing p:iteration-position "Both p:for-each
and p:viewport process a sequence of documents."

and that

"Within a p:viewport, the p:iteration-position and p:iteration-size are
taken from the sequence of documents that will be processed by the
p:viewport. The total number of documents is the p:iteration-size; the
ordinal value of the current document (the document appearing on the current
port) is the p:iteration-position.?"


So I'm wondering what is being conveyed by the descriptions regarding
viewport as working with a sequence of documents or single documents. Is
this a contradiction or is there a reason the spec speaks of sequences of
documents and a single document with relation to viewport?


Regards
Alex





On Wed, Feb 2, 2011 at 1:14 PM, Jostein Austvik Jacobsen <
josteinaj@gmail.com> wrote:

> Also, viewports are useful for other stuff than just modifying a document.
>
> For instance, what if you wanted to store all HTML elements as separate
> HTML files but ignore all TEXT elements? in this case p:modifySubtree
> and p:modifyNode wouldn't be meaningful.
>
> I look at p:viewport as a kind of advanced version of p:for-each. If it had
> to be renamed, then maybe p:for-each-match ?
>
> Anyway, I like "p:viewport" - both the step and it's name :)
>
> Regards
> p:viewport-fan
>
> 2011/2/2 <vojtech.toman@emc.com>
>
> > Vojtech,, although I understand your points fully they
>> > speak to me that viewport is talking about something
>> > other than xml documents.
>>
>> Yes, the original viewport definition(s) may be unrelated to XML, but that
>> does not mean we cannot take existing concepts and apply them to XML, or to
>> any other area.
>>
>> Regards,
>> Viewport :)
>>
>>
>> --
>> Vojtech Toman
>> Consultant Software Engineer
>> EMC | Information Intelligence Group
>> vojtech.toman@emc.com
>> http://developer.emc.com/xmltech
>>
>>
>>
>>
>


-- 
Alex
-----
Currently:
Freelance Software Engineer 6+ yrs exp
 <http://www.facebook.com/pages/Bafila/125611807494851>
Previously:
https://sites.google.com/a/utg.edu.gm/alex/


A Bafila, is two rivers flowing together as one:
http://www.facebook.com/pages/Bafila/125611807494851

Received on Saturday, 5 February 2011 12:10:16 UTC