I haven't read all the thread so apologies if I am re-making some point, or saying something dumb that has been pointed out.
Three quick points.
1.
If your schema is recursive, then the problem of determining whether it
is always correct is NP, isn't it? Infinite number of inputs. Which, if
so, probably needs to limit or condition our expectations or
approaches.
2. Obviously
people use Schematron to validate pre and post conditions, including
co-constraints between input and output all the time. it is a common
use.
(Where Schematron
is lacking is that it does not have a built in mechanism to force
completeness: obviously it can report if there are unexplained elements
that no rule in a pattern catches, but it cannot enforce eg if there is
an element found that is caught by no pattern... though you can make
another pattern for that. )
What
becomes useful (unless every element name is only used once per document instance) is for the
transformation to generate some tracing data; so that e.g. for
each output element we know which element ID or xpath of the input document(s) generated it. That
gets rid of many logical errors: the issue is rarely "does this input
value appear in the output" but rather "does this input value appear in
the output because it actually came from that input?"
3.
The problem might be considered as a category error: we do not actually
want to validate the Inputs and outputs, we want to validate the XSLT. I
came up with an approach for a bank years ago where I converted an XSLT
into just the possible element branches it could generate. This then
could be stitched in with other similar data from subsequent stages in
the pipeline, so that the result was an abstract document (on a
spreadsheet) that showed for each input what elements could appear in
the final output. This helped them feel on top of the pipeline, to
reason about flaws and behaviour, without needing XSLT expertise.
This
then could be paired with data extracted from a schema: for example to
just do pairwise tests: for every parent/child in the abstract output,
is it an allowed pair by the output schema? (IIRC James Clark put in a
partial validation mode in Jing that allowed you to just test
parent-child constraints not sequence or absense: this could be useful
too. ) Are any required pairs missing in the input or output?
Rick