I would like to see some support for processing synchronized documents. I mean where you process nodes in document S (slave) by looking at what "corresponding" nodes in document M (master or model) are, BUT coping with gaps in both (where M does not have corresponding nodes, and where M has nodes that with no correspondence in S).
It is something like this: map each node in S & M to some signature (a XPath with key), then for each S or gap-in-S process corresponding [S,M] pairs with the same key or handle gaps where a key does not have a partner.
Traversing two identical trees is easy in XSLT, but it falls down when there are gaps, and I cannot help but wondering if there is some primitive missing.
The use case here is end-to-end inspection of complex multi-stage multi-inout/output transformation pipelines, or even AB unit tests. So not QA but QC, validation but verification: comparison of outputs against inputs rather than schemas. Testing conservation of document variants rather than testing invariants, if you like.
Strawman: It could be something like this:
<xsl:model href=""/>
<xsl:template
match="section[@type='group1']/heading" priority="2"
model-match="group1/title" model-priority="3"
key="count(preceding::section[@type='group1'])"
model-key="count(preceding::group1)" >
<xsl:choose>
<xsl:when test="model-current() != node()">
.. no corresponding model match
</xsl:when>
<xsl:if test="current() != node() or current()=()" >
... missing item that model has item for
<xsl:variable name="INDEX" select="model-key()/>
<xsl:push mode="second-pass"
select="//section[@type='group1'][count(preceding::section[@type='group1'])= $INDEX - 1]"
position="after">
<xsl:call-function name="handle-missed-group1">
<xsl:with-param name="model" select="model-current()"/>
</xsl:call-function>
</xsl:push>
</xsl:when>
<xsl:otherwise>
... normal processing
</xsl:otherwise>
...
So this is
0) an element xsl:model to set the model document and enable these features.
1) an element xsl:push (or xsl:defer or xsl:future or xsl:thunk or whatever) which queues a function to be run after/before some context is matched in a particular mode that must be explicitly apply-templated sometime.
2) xsl:template is extended to also match some model with a corresponding key, or gaps in either.
3) a function model-current() is added to retrieve the model and context. A function model-key() retrieves the model key value.
Or is there some way to do this already, without being in a some elaborate mess?
Regards
Rick