Re: [xsl] XSLT Streaming - How to consume same node twice.

Subject: Re: [xsl] XSLT Streaming - How to consume same node twice.
From: "Mailing Lists Mail daktapaal@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Aug 2016 23:07:58 -0000
Thanks Michael.
i looked at the code like million times wondering why it isnt working..
Vasu

On Tue, Aug 23, 2016 at 6:03 PM, Michael Kay mike@xxxxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> You're so close: you've used xsl:fork, which is the way to tackle this, but
> you have used it wrong.
>
> Replace
>
> <xsl:fork>
>   <xsl:sequence>
>     ....
>   </xsl:sequence>
> </xsl:fork>
> <xsl:fork>
>   <xsl:sequence>
>     ....
>   </xsl:sequence>
> </xsl:fork>
>
> by
>
> <xsl:fork>
>   <xsl:sequence>
>     ....
>   </xsl:sequence>
>   <xsl:sequence>
>     ....
>   </xsl:sequence>
> </xsl:fork>
>
> Of course, xsl:fork compromises streaming: essentially, it allows the input
> to be streamed, but the output will typically need to be buffered so it can
> be reassembled in the right order.
>
> Michael Kay
> Saxonica
>
>
> On 23 Aug 2016, at 21:02, Mailing Lists Mail daktapaal@xxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
>
> Hi All,
>
> I want to consume one node twice. If I were using a URL for streaming, I
> know how to do this, but when I am using an XSL to be run with an XML, i am
> having difficulties doing the same
>
> I have the following XML
>
>
> <RootNode>
> <Groups>
> <Group>
> <specifics>
> <specific>Subgroup1</specific>
> <specific>Subgroup2</specific>
> </specifics>
> <Group_Detail>
> <GroupIdentifier>G1</GroupIdentifier>
> </Group_Detail>
> </Group>
> <Group>
> <specifics>
> <specific>Subgroup3</specific>
> <specific>Subgroup4</specific>
> </specifics>
> <Group_Detail>
> <GroupIdentifier>G1</GroupIdentifier>
> </Group_Detail>
> </Group>
> <Group>
> <specifics>
> <specific>Subgroup1</specific>
> <specific>Subgroup2</specific>
> </specifics>
> <Group_Detail>
> <GroupIdentifier>G3</GroupIdentifier>
> </Group_Detail>
> </Group>
> <Group>
> <specifics>
> <specific>Subgroup5</specific>
> <specific>Subgroup6</specific>
> </specifics>
> <Group_Detail>
> <GroupIdentifier>G2</GroupIdentifier>
> </Group_Detail>
> </Group>
>
> </Groups>
> </RootNode>
>
> XSLT that we need to run on this is :
>
>
> <xsl:transform version="3.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:mode name="stream" streamable="yes" on-no-match="shallow-copy"/>
> <xsl:output method="xml" indent="yes"/>
>
>   <xsl:template match="/" mode="stream">
>
> <xsl:result-document href="fileout.xml">
> <xsl:apply-templates mode="stream"/>
> </xsl:result-document>
> </xsl:template>
> <xsl:template match="Groups" mode="stream">
> <xsl:fork>
> <xsl:sequence>
> <xsl:copy>
> <xsl:for-each select="Group/copy-of(.)">
> <Formatted-Group groupId="{Group_Detail/GroupIdentifier}">
> <xsl:copy-of select="specifics"/>
> </Formatted-Group>
> </xsl:for-each>
> </xsl:copy>
> </xsl:sequence>
> </xsl:fork>
> <xsl:fork>
> <xsl:sequence>
> <aggregated>
> <xsl:for-each select="Group/copy-of(.)">
> <Aggregated groupId="{Group_Detail/GroupIdentifier}">
> <xsl:copy-of select="specifics"/>
> </Aggregated>
> </xsl:for-each>
> </aggregated>
> </xsl:sequence>
> </xsl:fork>
> </xsl:template>
> </xsl:transform>
>
>
> I am sure this is wrong.. but what can be done to correct this.. I know,
> that if I had a URL i could stream , then I would have written
>
> <xsl:stream href="{$fileHref}">
>
> <aggregated>
> <xsl:for-each select="/RootNode/Groups/Group/copy-of(.)">
> <Aggregated groupId="{Group_Detail/GroupIdentifier}">
> <xsl:copy-of select="specifics"/>
> </Aggregated>
> </xsl:for-each>
> </aggregated>
>
>
> </xsl:stream>
>
>
>
> Is there something similar I can use when I am not using File URL as the
> input?
>
>
> Dak Tapaal
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)

Current Thread