OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

relax-ng-comment message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Public Comment


Comment from: arobert@cogsci.ucsd.edu

This comment is in response to a thread that recently appeared on the relax-ng-comment archive by Sean McGrath, relating to a problem with schema inclusion.


Regarding the multiple inclusion problem raised, John Cowan writes in response:

> > Back in my C programming youth, I would use use "#ifndef" :-) How best
> > to handle in Relax NG?

> NRL is probably your friend in this case.

and Murata Makoto writes:

> You might want to use nested grammars for avoding conflicts.


I have been facing a similar situation to Mr. McGrath, and neither of these solutions is satisfactory.  Using Namespace Routing Language requires the use of separate namespaces in schema components, and it also brings in a whole additional layer of specification, a new language to wait for implementations of, etc..  Using nested grammars restricts access from outside the nest to only the 'start' pattern defined inside.

Consider the following simple case, which is not addressed by either solution:

- schema "utils.rng" defines a number of common utility elements (e.g., 'person', 'email_address', 'url', etc.)

- schema "basic-defs-1.rng" and "basic-defs-2.rng" define some basic structures that are less general than "utils", but still of broad utility (e.g., 'employee', 'applicant', 'resume'); they includes "utils" and uses several of its elements; both are in the same namespace, but kept separately for modularity and maintenance reasons

- schemas "document-type-1.rng", "document-type-2.rng" define actual document types in use by an organization; they each declare their own separate namespaces but include both "basic-defs-1" and "basic-defs-2"

I would argue that this type of situation arises almost any time you want to define a non-toy system of schemas with some shared definitions.  The only way to make it work in Relax is to put only one reusable definition per schema file and use nested grammars.  But compared with OO frameworks (which, desires for XML purity aside, are often the sources of structures that we try to model in XML), this is intolerably clunky.  Even in one-class-per-file Java (a pattern that is optional, BTW) you can still access any number of methods from a class, rather than just the single identifier with a Relax-NG nesting.

The writers of the XHTML schema wanted so desperately to avoid this proliferation that they resorted to the hack of leaving some things undefined in the component schemas and relying on their definitions being included before they are in any schema that uses them.  This is not only ugly but would become a maintenance nightmare in any open system.  It also prevents building frameworks where the components are first-class usable schemas in their own right.

It seems like all of this could be solved, with no ill effects, simply by stipulating that a Relax-NG processor should process a schema file only once.  (If desired, an "import" keyword could be added to the language for this meaning to preserve backwards compatibility.)  I have read some other requests for this feature expressed on the net, but I have never seen a good reason given for not implementing it.  If it is because of some philosophical objection based on elegance or mathematical correctness, I urge a reconsideration of the matter in which the philosophical distatefulness of the practical measures that users are forced to take in response are weighed against this.


Adrian Robert




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]