w3c Schema naming patterns and template-based schema generation

  • Thread starter Steve Jorgensen
  • Start date
S

Steve Jorgensen

In a schema I've been working on recently, a convention I evolved was to use a
consistent naming pattern such that, for instance, a Resident could appear in
a ResidentSet, and could be referred to by a ResidentRef, and the same pattern
would apply to other types of entities. That amounts to a lot of duplication
in the schema, though, and results in a need to enforce consistency in how the
naming convention is applied.

A solution I've come up with is to have a template schema file in which any
element can be a template for any pattern (by using an attribute from the
template system's namespace) where patterns are described in annotation
elements of the schema, each pattern contains one or more cases, and each case
indicates a set of text replacements represented as clause/text pairs. Each
template, then, gets output multiple times, once for each case in its pattern,
and for each case, any text matching the clause text in any attribute, element
text content, comment, or processing instruction is replaced with the
corresponding replacement text.

My questions for this group are...

1. Does anyone else think this is worthwile?
2. What should this system be called? Currently, I'm calling my prototype
SchemaSquared.xsl. Schema Squared refers to the fact that the template file
is sort of applied to itself. It contains both template code and expansion
case information to apply to the templates to produce the final xsd.

If you're on the fence as to whether this would be useful, here are some more
details, but please note that I'm not digging for approval here. I'm really
hoping for honest opinions of whether this is a good idea or not. If enough
people like the idea, I'll make a sourceforge project for it.

More details...

A template schema is also a valid schema unto itself and can be directly
validated by xsl editors like oXygen and XML Spy even though it can't be used
directly (without expanding first) to validate useful XML documents.

If one or more cases of any template need to be overridden by another
implementation, just make a sibling element that includes an override
attribute specifying the case it overrides. Replacements for the case are
still performed on an override so that, by using clauses, it can be valid in
the non-expanded template schema even if it has element references to other
globally defined elements requiring template expansion.

Template patterns can occur at any depth within the schema, and will be
replicated at the place they occur as multiple siblings. Template expansions
can be nested - a template element can contain other template elements for
different patterns.

I have an XSL file that right now that is surprisingly clear and short and
implements all of the functionality descibed here, but with some quirks to
work out such as correctly handling different prefixes for schema elements in
the template schema file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top