Re: [xsl] inheritance and encapsulation in xslt? / xslt for xlink?

Subject: Re: [xsl] inheritance and encapsulation in xslt? / xslt for xlink?
From: Howard Stearns <stearns@xxxxxxxxxxxx>
Date: Tue, 22 Jul 2003 14:29:48 -0400
David and Jeni ask about subsitution groups.

XBRL does make use of substitution groups for top level elements. I'm not certain why they also use arcs, and I'm not certain if they're used recursively within specialized taxonomies. In my first message I supposed that substitution groups could not be used more than one level deep, but rereading the XML Schema spec suggests to me that multiple transitive levels are just fine.

Maybe it has to do with lack of support (e.g., in XSLT tools) for substitution groups.

Also, there are really two kinds of element inheritance: "kind-of" (general-special) and "part-of" (child-parent or "part/whole"). Even if substitution groups are transitive, I think they conceptually map to kind-of relationships only. However, if there isn't a specialized transform for an element, and there isn't an available kind-of relationship that provides one, we might want to use a part-of relationship to find a transform. (You might think such multiple inheritance paths is intractable, but it's been used for years in expert systems with few problems.)

XBRL uses arcs for all kinds of extensibility: computations, presentation ordering, references to defintions in other literature, footnotes and explanations, etc. Maybe the idea is that tools should be able to read such arcs for these purposes, so it makes sense to use this mechanism for kind-of (and part-of) roles, too.

David Carlisle wrote:
> actually using xlink to get this processing seems rather odd. ...
> XSLT1 of course doesn't see the XSLT at all so it can't automatically
> read anything in teh schema, but even xslt2 which can know about the
> schema structure wouldn't see this. If you (they) ae going to use xsd
> why didn't they use xsd facilities for this? If for example the new
> elements were in the substitution group of the old ones xpath2 would
> automaticaly be able to cope.

Jeni Tennison wrote:
XML Schema is designed to manage this kind of situation (specialised
elements used in place of general elements) using substitution groups.
If you were using substitution groups instead of this XLink mechanism,
then Schema-Aware XSLT 2.0 processors would be able to pick up on the
fact that the <acme_slushFundCash> is a member of the substitution
group <ci_unrestrictedCash>. You could then write templates like:

<xsl:template match="element(ci_unrestrictedCash)">

and this template would be used for every element that belonged to the
ci_unrestrictedCash substitution group. You could also have
specialised templates for the specialised elements, using template
priority or import priority to override these more general ones.

So this would tackle precisely the problem that you're encountering,
but it's very much something for the future, since:

  (a) you're not using substitution groups in your schema, from what I
      can tell
  (b) XSLT 2.0 isn't yet a standard
  (c) there aren't any (even experimental) Schema-Aware XSLT 2.0
      processors around that you could use

XSL-List info and archive:

Current Thread