Re: Multiple Outputs from XSLT and Sequence Splitting

Jeni Tennison wrote:
> 
> Alex Milowski wrote:
>> Problem: A user uses a stylesheet that produces more than one result
>>          document.  What is the output of an XSLT step?
>>
>> I think the simplest answer is that you get a sequence of documents
>> from that step.
> 
> Agreed. (From an XSLT 2.0 step, anyway.)

Or XSLT 1.0 with an extension function for multiple outputs.

> 
>> The problem is now that you may want to do different things with
>> different documents from the sequence from the XSLT transform.  We
>> can solve this with group by using a component that creates a
>> subsequence from a sequence of documents based on an XPath expresison:
> 
> I thought that we were going to use the select attribute on a <p:input> 
> for this.
> 
> So:
> 
>  <p:step ...>
>    <p:input port="documents" source="transform!result"
>             select="/article" />
>  </p:step>

Yes, that is another possibility.  That doesn't solve the problem
of the sequence having to go to multiple places.

> Or that people could use a <p:choose> within a <p:for-each> to select 
> the appropriate course of action:
> 
>  <p:for-each>
>    <p:declare-input port="document" source="transform!result" />
>    <p:declare-output port="articles" source="choice!article" />
>    <p:declare-output port="html" source="choice!html" />
>    <p:declare-output port="others" source="choice!other" />
>    <p:choose source="!document" name="choice">
>      <p:when test="/article">
>        <p:declare-output port="article" source="!document" />
>        <p:declare-output port="html" />
>        <p:declare-output port="others" />
>      </p:when>
>      <p:when test="/html:html">
>        <p:declare-output port="article" />
>        <p:declare-output port="html" source="!document" />
>        <p:declare-output port="others" />
>      </p:when>
>      <p:otherwise>
>        <p:declare-output port="article" />
>        <p:declare-output port="html" />
>        <p:declare-output port="others" source="!document" />
>      </p:otherwise>
>    </p:choose>
>  </p:for-each>

This does solve the problem of the sequence going to multiple places.  I
guess I withdraw the need for a language construct.  The for-each+choose
method is probably good enough and can be done efficiently.

--Alex Milowski

Received on Sunday, 10 September 2006 20:18:40 UTC