Lab 7. Show the name and cost (USD) of each juicer

Redo lab 6 (show the name and cost of each juicer) but
this time use xsl:fork

After you have completed the lab, scroll down and read
my note (no peeking!)




















































Post to the Saxon mailing list:

Subject: Saxon scrambles the output of xsl:fork

I am using xsl:fork to output the name and cost of each juicer:

--------------------------------------------------------------
    <xsl:mode streamable="yes" />
    
    <xsl:template match="/">
        <Juicers>
            <xsl:for-each select="juicers/juicer">
                <Juicer>
                    <xsl:fork>
                        <xsl:sequence>
                            <Name><xsl:value-of select="name" /></Name>
                        </xsl:sequence>
                        <xsl:sequence>
                            <Cost><xsl:value-of select="cost[@currency eq 'USD']" /></Cost>
                        </xsl:sequence>
                    </xsl:fork>
                </Juicer>
            </xsl:for-each>
        </Juicers>
    </xsl:template>
--------------------------------------------------------------

I expected to see this form for each juicer:

<Juicer>
      <Name>Mighty OJ Juicer</Name>
      <Cost>49.99</Cost>
</Juicer>

Instead, I get this scrambled output:

<Juicer>
      <Name>
            <Cost>OJ Home Juicer</Cost>
            41.95
      </Name>
</Juicer>

I suppose that output is actually not unreasonable since the prongs of fork may be done in parallel, yes?

But maybe not. I plain don't know.

Is that output a bug in Saxon? If it's not a bug, how do I produce the desired output, when using xsl:fork?



