Re: p:replace

/ Alex Milowski <alex@milowski.org> was heard to say:
| One technical problem that it does not address is that it
| assumes the document sequence (e.g. replacement) can be produced
| externally.
|
| In all of my uses of my 'subtree' step in smallx, I take the
| element that matched and use it to *produce* the replacement.  As
| such, the above component, as described, would not work.

Sure it would, you could use a for-each to generate the sequence.

| Also, this kind of component is practically impossible to stream.

Yeah, that might be a show-stopper.

Ok, then, here's an attempt to define a viewport (or peephole)
component.

p:viewport replaces portions of a document with the result of applying
a sequence of steps.

<p:viewport name="QName">
  <p:declare-input ref-each="reference" select="//..." .../>
  <p:declare-output port="..."/>

  { components }

</p:viewport>

The declare-input associates an input a local port name. For each
document in the input sequence, the p:viewport component finds each
portion of the document that matches the select expression, constructs
a document from that portion, and applies the component sequence to
that document. The result of each application replaces the original
matched nodes in the input document.

The output of the viewport component is a copy of the original
document with the selected portions replaced as specified.

It is an error if more than one declare-input is provided, if the
declare-input does not specify a select expression, or if more than
one declare-output is specified.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
XML Standards Architect
Sun Microsystems, Inc.

Received on Monday, 31 July 2006 15:21:44 UTC