Re: Multiple Outputs from XSLT and Sequence Splitting

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.)

> 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>

would select the <article> document elements from the documents from the 
transform!result source, and turn them into documents, thus effectively 
selecting only the articles from the sequence of documents.

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>

Cheers,

Jeni
-- 
Jeni Tennison
http://www.jenitennison.com

Received on Sunday, 10 September 2006 08:05:04 UTC