xsl-list
[Top] [All Lists]

Re: [xsl] Accumulator use

2016-02-29 05:39:28
cmarchand(_at_)oxiane(_dot_)com wrote:

I try to cache values who are in external files referenced from my
source file :

source.xml
------------
<root><input href="1.xml"/><input href="2.xml"/>...</root>

n.xml
------
<root type="typeN">...</root>

I want to create a map(xs:anyUri, xs:string), where key is the external
file URI, and value is always /*/@type in the file

If the files are huge but you only need the @type attribute of the root element then using `xsl:iterate` and `xsl:break` for an early exit, as described in http://saxonica.com/html/documentation/sourcedocs/streaming/partial-reading.html might be the best approach to avoid parsing the large documents.


External files may be huge, and I'd like to stream them. I create an
accumulator, stream input files using this accumulator.

<xsl:accumulator name="acc" as="map(xs:string, xs:string)"
initial-value="map{}">
    <xsl:accumulator-rule match="*[@value]">
       <xsl:sequence select="map:put($value, ./local-name(),
xs:string(./@value))"/>
    </xsl:accumulator-rule>
</xsl:accumulator>

Above you say map(xs:anyUri, xs:string) with the key being the file URI, so why is the accumulator map(xs:string, xs:string) and stores the local name and not the URI?

<xsl:mode name="m" streamable="yes"/>

<xsl:template match="/">
    <xsl:stream href="../../test/resources/entries.xml"
use-accumulators="acc">
       <xsl:apply-templates mode="m"/>
    </xsl:stream>
    <!-- do here something that uses the accumulator -->
</xsl:template>

Where do you parse the referenced files?
--~----------------------------------------------------------------
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>