Adrian
Adrian

Reputation: 59

Error : "An accumulator rule that matches attribute or namespace nodes has no effect"

This is my data

    <ECC>
       <Grp EId="2123" CC="1"/>
       <Grp EId="4345" CC="1"/>
       <Grp EId="1074" CC="2"/>
       <Grp EId="1254" CC="1"/>
       <Grp EId="1342" CC="3"/>
       <Grp EId="1261" CC="1"/>
    </ECC>

I'm trying to load this into an accumulator using this

    <xsl:accumulator name="CurrentLookupValue" as="xs:string" initial-value="''" streamable="yes">
        <xsl:accumulator-rule match="ECC/Grp/@EId/text()" select="."/>
    </xsl:accumulator>

    <xsl:accumulator name="EmplIDLookup" as="map(xs:string,xs:decimal)" initial-value="map{}"
        streamable="yes">
        <xsl:accumulator-rule match="ECC/Grp/@CC/text()"
            select="map:put($value, accumulator-before('CurrentLookupValue'), xs:decimal(.))"/>
    </xsl:accumulator>

I get the warning "An accumulator rule that matches attribute or namespace nodes has no effect"

Documentation says "Pattern defining the set of nodes to which the accumulator rule applies" Is there a workaround to use attributes? Or should I create this xml in nodes?

Upvotes: 0

Views: 208

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167716

@EId/text() does not make any sense as attribute nodes don't have any child nodes.

In general, as even with streaming you can read out attributes when matching on an element node I think you simply want

<xsl:accumulator name="CurrentLookupValue" as="xs:string" initial-value="''" streamable="yes">
    <xsl:accumulator-rule match="ECC/Grp" select="string(@EId)"/>
</xsl:accumulator>

and

<xsl:accumulator name="EmplIDLookup" as="map(xs:string,xs:decimal)" initial-value="map{}"
    streamable="yes">
    <xsl:accumulator-rule match="ECC/Grp"
        select="map:put($value, accumulator-before('CurrentLookupValue'), xs:decimal(@CC))"/>
</xsl:accumulator>

or simply one accumulator

<xsl:accumulator name="EmplIDLookup" as="map(xs:string,xs:decimal)" initial-value="map{}"
    streamable="yes">
    <xsl:accumulator-rule match="ECC/Grp"
        select="map:put($value, string(@EId), xs:decimal(@CC))"/>
</xsl:accumulator>

Upvotes: 2

Related Questions