467,077 Members | 952 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,077 developers. It's quick & easy.

w3c Schema naming patterns and template-based schema generation

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.

Aug 9 '05 #1
  • viewed: 933
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Shemp | last post: by
4 posts views Thread by Tony Ha | last post: by
8 posts views Thread by NKOBAYE027 | last post: by
4 posts views Thread by Mark Broadbent | last post: by
114 posts views Thread by Jonathan Wood | last post: by
5 posts views Thread by Allen | last post: by
17 posts views Thread by Miguel Guedes | last post: by
2 posts views Thread by vital | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.