[relaxng-user] trang and xsd-friendly schemas

G. Ken Holman gkholman at CraneSoftwrights.com
Mon Sep 13 07:42:37 ICT 2004


At 2004-09-11 23:51 -0400, Bruce D'Arcus wrote:
>OK, I'm working on a schema for which I am taking advantage of RELAX 
>NG-specific features like interleave and attribute-based validation
>...
>I would like to be able to get a clean XSD using Trang.

I see the above two requirements as irreconcilable.  You can have one or 
the other, but you cannot have both.

>Trang will convert the current schema to XSD, but when I try to validate 
>an instance against it, I get errors related to the following original RNC 
>patterns:

Sure you do ... all of the errors that were reported make sense to me and I 
couldn't express them any better myself.  You've asked for non-XSD 
semantics in XSD syntax, so unsurprisingly you are going to get errors 
reported regarding what is or is not allowed in the semantics of a document 
model described by XSD.

>Any suggestions on how to better handle this?

"Handle" what?  You are asking for and getting the XSD syntax of your 
choice in semantics, and those semantics are not supported by XSD.

One strategy is to express the XSD "permissively" so as to qualify a 
superset of the documents that you want, and then use a second pass with a 
technology like ISO/IEC 19757-3 Schematron to post-process your instance to 
check the things that cannot be checked in XSD.  Looking at the invocation 
of trang, I do not see any parameters that would produce a companion 
Schematron expression with an XSD expression.

>Also, is there any problems using interleave in this context?

In the context of XSD?  XSD doesn't support the interleave modeling semantic.

>I have a few patterns that look like this:
>
>         Part = element part-details { Formatting.Attributes, ( Volume? & 
> Issue? & Pages? & Date? ) }

Because of ambiguity, you'll never be able to express in XSD the precise 
semantics available to you in RELAX-NG.  If you changed the interleave into 
a simple alternate pattern ("OR") then use a second pass Schematron pattern 
to confirm the presence of at most one of any of the choices, then with the 
two expressions you will have mimicked the interleave of RELAX-NG.

Remember that document modeling languages have two components:  the 
semantics of what validating processors are allowed to do with XML 
instances and the syntax that allows users to express which of those 
semantics they want for their document models.

When I teach the differences between schema languages, I first teach all 
the many semantics possible when modeling documents, then looking at each 
of the expression languages in turn I convey to students which of the 
semantics are supported by which of the expressions.  That way new users 
who need to do document modeling are choosing the expression language they 
need to express the validation semantics they need, rather than choosing an 
expression language for arbitrary reasons first and then having to live 
with or accommodate shortcomings that are not meeting their modeling 
requirements.

Many people go the other way around: they choose a modeling language then 
try to shoehorn their needs into it.

You are asking for the semantics of RELAX-NG to be supported by XSD 
processors, which cannot happen unless you limit yourself to that subset of 
RELAX-NG semantics that happens to be supported by XSD processors.  When 
you have chosen to use only those semantics supported by XSD then the trang 
translation will produce an XSD that won't give you errors.

I hope this helps.

............................... Ken

--
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/r/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/r/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal



More information about the relaxng-user mailing list