w3c Schema naming patterns and template-based schema generation

Discussion in 'XML' started by Steve Jorgensen, Aug 9, 2005.

  1. 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.
     
    Steve Jorgensen, Aug 9, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frank
    Replies:
    9
    Views:
    1,569
    David Dorward
    May 3, 2004
  2. crichmon
    Replies:
    4
    Views:
    485
    Mabden
    Jul 7, 2004
  3. Replies:
    1
    Views:
    373
  4. Harman
    Replies:
    1
    Views:
    2,510
    Moiristo
    Jul 28, 2006
  5. vital

    Patterns and Naming Coventions

    vital, Dec 2, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    287
    Eliyahu Goldin
    Dec 2, 2007
Loading...

Share This Page