[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Question on XSLT streaming and accumulation of values

Subject: Question on XSLT streaming and accumulation of values
From: "Felix Sasaki felix@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 15 Oct 2017 19:26:16 -0000
 Question on XSLT streaming and accumulation of values
Accidentally I sent the below mail to the wrong mail address, and inbetween
found a solution to the issue: using for the accumulator
match="group-meta1/text()" select="string(.)"

In case there are other solutions, I am eager to learn about them .


I have an XML input of the following structure

    <GROUP>
        <group-meta1>metainfo-group-1</group-meta1>
        <TRANSACTION>
            <transaction-meta>
                <transaction-meta1>metainfo-transaction-1</transaction-
meta1>
            </transaction-meta>
            <loop1>...</loop1>
            <loop2>to be done1</loop2>
            <loop2>to be done2</loop2>
        </TRANSACTION>
    </GROUP>

I want to process all loop2 elements with XSLT 3.0 streaming. For each
loop2 element, there should be a uri generated which is defined as follows:

    value of group-meta1 + "/" + value of group-meta2 + "/" + loop2 number

That is for the loop2 with the value "to be done" the uri

    /metainfo-group-1/metainfo-transaction-1/1.xml

And for the second loop2 the uri

    /metainfo-group-1/metainfo-transaction-1/2.xml


Is this possible with streaming? I tried templates gathering the
metainformation, but that works only if I use copy-of to gather the
meta-information, e.g. in this template:

<xsl:template mode="process-loop2" match="GROUP">
        <xsl:variable name="current-group" select="copy-of(.)" />
        <xsl:apply-templates mode="process-loop2" select="$current-group/*">
            <xsl:with-param name="group-meta1" select="$current-group/group-
meta1"/>
        </xsl:apply-templates>
    </xsl:template>


The issue with this solution is that I need to keep the whole GROUP element
in memory, via copy-of(), and a group already can be several gigabyte. With
saxon, that leads to an out-of-memory error.

I guess the problem is that I want to do two things within one stream: go
into the metadata subtrees of GROUP or TRANSACTION, and use that
information in the loop2 nested elements, which are not in the metadata
subtrees. That may not be possible.

I found a solution with streaming accumulators for gathering the GROUP
position:

<xsl:accumulator name="group-position" as="xs:integer" initial-value="0"
streamable="yes">
 <xsl:accumulator-rule match="GROUP" select="$value + 1" />
</xsl:accumulator>

But I did not find a solution for gathering with a streaming accumulator,
and then using the value of group-meta1, in the uri construction template.
An accumulator as follows
<xsl:accumulator name="group-meta" as="xs:integer" initial-value="0"
streamable="yes">
 <xsl:accumulator-rule match="group-meta1" select="." />
</xsl:accumulator>

Gives me an error that the accumulator needs to be motion less.

Best,

Felix

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.