xsl-list
[Top] [All Lists]

Re: [xsl] streaming XSLT creating a header from a first record

2018-05-08 13:11:07
On 08.05.2018 18:04, Michael Kay mike(_at_)saxonica(_dot_)com wrote:
I don't think you need two accumulators, you can have a single accumulator that 
matches every row and only creates the map if the current value is an empty map.

Taking up that idea I tried also to construct a streaming accumulator that stores a (shallow) copy of the first row element and a deep copy of its attributes:

<xsl:accumulator name="first-row-copy" as="element(row)?" initial-value="()" streamable="yes">
                <xsl:accumulator-rule match="table/row">
                        <xsl:choose>
                                <xsl:when test="empty($value)">
                                        <xsl:copy>
                                                <xsl:copy-of select="@*"/>
                                        </xsl:copy>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:sequence select="$value"/>
                                </xsl:otherwise>
                        </xsl:choose>
                </xsl:accumulator-rule>
        </xsl:accumulator>

Seems to also work fine. So in that case one doesn't need to switch between XML and maps when processing the stored value but can continue to use the traditional XSLT processing of XML.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>