[Top] [All Lists]

Re: [xsl] accumulators and continuous numbering

2019-10-18 15:21:28
On 18.10.2019 21:08, Graydon graydon(_at_)marost(_dot_)ca wrote:
So I'm converting a bunch of OOXML into DITA using XSLT 3 in oXygen with Saxon PE.

There's a requirement to use short (4 digit) unique identifiers for the
resuling files and for these to be unique across the content set.  There are
many resulting DITA files per source OOXML document.

"A chance to try accumulators!" I thought; I can pre-process the whole thing
with file numbers in attributes.  This isn't an attempt to use streaming; I've
got a few tens of MB of source.

The accumulator works, BUT the number sequence restarts if I try to use the
accumuator across a sequence of document nodes or a sequence of element nodes.

To produce a single continuous sequence of monotonically increasing integers
with the accumulator, I have to get the whole content set into the same tree
before creating the numbering attributes.

Is that the expected behaviour?

Yes, I think so, an accumulator is specific to a document.

I get one continous sequence of numbers.

Is there a better way to get the single continuous sequence of numbers?

If don't want to create a result tree then I think instead of

<xsl:variable as="element(w:document)+" name="numberedSrc">
 <xsl:apply-templates mode="fileNumber" select="$contentSet" />

you would need to use xsl:iterate select="$contentSet" and pass the
latest accumulator on as the parameter of xsl:iterate, like I have done
in https://xsltfiddle.liberty-development.net/bwdwrT

  <xsl:variable name="transformed-docs" as="element(root)*">
      <xsl:iterate select="$docs">
          <xsl:param name="sum" as="xs:integer" select="0"/>
              <xsl:with-param name="sum" tunnel="yes" select="$sum"/>
              <xsl:with-param name="sum" select="$sum +

Not sure whether that is anything better, it seems to be a bit too
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>