3

I've used Schematron to validate XML documents before. However, I now have a new use case I'm wondering about.

Does anyone know of any XSLT or Schematron Processor that can be used to validate an XSD (rather than an instance doc) in order to determine if any document conforming to that XSD could ever be capable of satisfying the Schematron requirements?

Background for my question. I'm considering messaging techniques for an SOA based architecture. I'm contemplating the Consumer Driven Contracts Model. In his writeup of the same from Martin Fowlers page (linked above), Ian Robinson describes using Schematron to validate incoming messages while still allowing for backwards and forwards compatibility if the schema of incoming messages changes.

Based on this, I'm contemplating the following:

  • Assume there is a service that represents the schema of it's messages in XSD.
  • Assume there is a consumer of this service, which validates incoming messages via Schematron.
  • Finally, assume there is a service registry where services publish their schemas, and consumers get notified of any change to a schema.

Given this scenario, I'm considering the possibility that the client could actually validate the schema itself to see if the new service contract violates the client's requirements.

EDIT

Based on the comment below from Mads Hansen, here's a little more detail.

I'm trying to define a service registry now, to be used by programmers in the future. So this is a necessarily broad problem. I'm trying to loosen up the relationship between services and consumers that rely on them, so as to provide room for the services to evolve. Think of the UML ball and socket notation, by which a designer can represent both provided contracts and required contracts. In my service registry, Services would register their provided contracts which would include an XML Schema to define the format of messages they send. Consumers would register Schematron documents defining the parts of those messages they are interested in. In the future, as the services evolve, the registry itself could provide warnings or possibly even block services from evolving in ways that break consumers. It would do this by validating service contracts against the schematrons of consumers who would use them.

I realize that I could write an XSLT that takes an XSD and a Schematron as inputs and does what I need, but I want to know if anyone's already done this. Hence the question: Does anyone know of any XSLT or Schematron Processor that can be used to validate an XSD (rather than an instance doc) in order to determine if any document conforming to that XSD could ever be capable of satisfying the Schematron requirements?

LTZJoe
  • 86
  • 6
  • 3
    This is very broad. It is possible to validate a schema against schematron rules. To know whether you could validate your rules, it would be helpful to provide some tangible examples. – Mads Hansen Oct 05 '16 at 12:15
  • 1
    Extremely interesting, but I think too that it is too broad for this site rules. Even if the question were simpler like ¿is it possible to programmatically determine if any XML document could be valid against a given Schematron? I think the answer is no, in general. It would be easier to think about a solution for your particular case (and not the general case), maybe creating a language or metalangue or not restricting to XSD+Schematron. I am offering a bounty to see if we can get a good or technical or complete or interesting answer. – sergioFC Oct 08 '16 at 19:57

0 Answers0