On 04/10/2010 21:53, Eliot Kimber wrote:
I have a transform that converts Word docs into sets of result documents. My
general technique is to pre-process the Word into a sequence of elements
annotated with the effective result level, defining the result hierarchy the
elements should generate.
Given this I can then use for-each-group group-starting-with to translate
the flat list into the appropriate hierarchy via essentially recursive
descent (that is, each level applies processing for the next level down to
the current group in the for-each).
However, I'm running into a problem when I have the case where a group at
level 1 and a group at level 2 both need to generate result documents.
So for example, I might have this Word input:
Where the desired result is three result documents, one for the first
Heading 1 paragraph and the Normal paragraph following it, one for the
Heading 2 and its following para and one for the last Heading 1.
In addition, I currently have the code written to apply at least two passes
of processing over the elements that will eventually be put into a document,
<xsl:apply-templates select="current-group()" mode="pass-one"/>
<xsl:apply-templates select="$resultDoc" mode="pass-two"/>
This works fine for one level of output (that is, a single result document
generated by highest group).
But if I have a nested group that also needs a result document as in the
example above then I get the failure "Cannot switch to a final result
destination while writing a temporary tree" which I guess makes sense (or at
least I accept that there must be a good reason for this restriction). This
is because the processing happening in mode "pass-one" may hit the part
shown above, meaning the processor is currently in the process of
constructing the value of "resultDoc" for the higher-level group.
I've puzzled over this problem and I'm not seeing an obvious solution but I
suspect that there's some relatively simple approach that would allow me to
generate multiple result documents.
The only thing that I've thought of so far is to have the main processing
logic generate a sequence of elements that I can process serially to
generate the required result documents.
Am I missing some non-obvious algorithm?
Hard to say at this level of generality but possibly you just need to
modify your grouping logic.
Given your flat sequence of headings and paras the _sectioning_ logic is
however if you insert xsl:result-document in that flow you'll get the
error that you showed.
However your description is essentially that documents contain the
initial fragments of level 1 or 2 sections, so that is something more like
Now it;s a lot safer to wrap the ... in an xsl:document
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>