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

Subject: [xsl] XSLT Streaming - How to consume same node twice.
From: "Mailing Lists Mail daktapaal@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 Aug 2016 20:01:50 -0000
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>b


</xsl:stream>



Is there something similar I can use when I am not using File URL as the
input?


Dak Tapaal

Current Thread