Multi-file Schematron architecture

This should cover W3C XML Schema, Relax NG and DTD related problems.

Multi-file Schematron architecture

Postby brent3600 » Tue Apr 10, 2012 9:58 am

I am trying to figure out how to construct a set of Schematron files that work together. For example, where an abstract pattern can reside in one Schematron schema and can be invoked by a pattern in another schema. Or where a set of schemas can be processed against an instance document using a single processing instruction in the instance message. I'm sure someone has already thought this out, and I'm hoping someone can point me in the right direction. I've considered the following possibilities:

My first thought was just to put multiple processing instructions in the instance messages, but it turns out that we can't do that.

My second thought was to simply invoke one schema from another using a namespace, ala "import" statements in XML Schema, but Schematron doesn't seem to be set up for that.

My third thought was to use include statements to pull content into a schema from external files. The problem is that whatever an include statement brings in has to fit into the Schematron hierarchy at the point of insertion. So from a schema you can include a pattern, but you can't include a schema. Supposedly you can set up include statements to include a specific entity in a file, and not the whole file, but I get error messages telling me I can't do that when I try it.

My fourth thought was to extend Schematron to create a layer between schema and pattern, phase, etc., which would facilitate "including" the entire contents of a schema without including the schema itself. I don't know how to do this.

So at this point I'm contemplating a setup where every pattern and abstract pattern "lives" in a separate file which gets included in a single schematron file. This could be workable but presents major complexity and management issues, obviously. I have the feeling that there must be a straight-forward way to do this.

Any pointers you can toss my way would be much appreciated.
brent3600
 
Posts: 3
Joined: Tue Apr 10, 2012 2:04 am

Re: Multi-file Schematron architecture

Postby george » Wed Apr 11, 2012 9:37 pm

Hi,

You summarized very well the possibilities. It is a pity that the include Schematron element did not work as many people expect that to work, that is to refer to a schema and to include all the patterns that are found in that schema.
AFAIK for the next version of Schematron there is a new Schematron element proposed that will perform exactly that processing.

One possibility is to use XInclude to bring in the patterns you want, but I am afraid that only the element XPointer scheme will work. Something like below:

test.xml
Code: Select all
<?xml-model href="test.sch" type="application/xml"
  schematypens="http://purl.oclc.org/dsdl/schematron"?>
<test>
 
</test>


test.sch
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
  <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="inc.sch" xpointer="element(/1/1)"/>
  <pattern id="p2" is-a="p1">
  </pattern>
</schema>


inc.sch
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron">
  <pattern id="p1" abstract="true">
    <rule context="test">
      <assert test="false()">test..</assert>
    </rule>
  </pattern>
</schema>


Best Regards,
George
George Cristian Bina
george
Site Admin
 
Posts: 2061
Joined: Thu Jan 09, 2003 2:58 pm

Re: Multi-file Schematron architecture

Postby brent3600 » Thu Apr 12, 2012 5:59 am

Thanks so much, George, for your thoughtful and detailed reply! Very useful. It sounds like a good solution. I'll try it out and let you know how it works for me. I really appreciate your taking the time to lay it out so well.

- Brent
brent3600
 
Posts: 3
Joined: Tue Apr 10, 2012 2:04 am

Re: Multi-file Schematron architecture

Postby brent3600 » Sun Jul 01, 2012 12:33 am

The suggested approach still looks good, but I've run into a problem. It would appear that Xerces only supports the XPointer element scheme, not the full XPointer standard. In particular, the XPath scheme in XPointer is not supported. Is there an alternative XML parser that supports XML Schema, Schematron, XInclude, XPath, and XPointer, specifically the XPath scheme in the latter? And that can be attached to Oxygen . . .
brent3600
 
Posts: 3
Joined: Tue Apr 10, 2012 2:04 am

Re: Multi-file Schematron architecture

Postby george » Mon Jul 02, 2012 11:11 am

As far as I know there is not such XML parser for Java - if you find one let me know :).
George Cristian Bina
george
Site Admin
 
Posts: 2061
Joined: Thu Jan 09, 2003 2:58 pm


Return to XML Schemas

Who is online

Users browsing this forum: No registered users and 0 guests