- From: Roger L. Costello <costello@mitre.org>
- Date: Tue, 16 Apr 2002 10:24:05 -0400
- To: Jeni Tennison <jeni@jenitennison.com>
- CC: xmlschema-dev@w3.org, paul.w.daisey@census.gov, Simon.Cox@csiro.au, costello@mitre.org
Jeni Tennison wrote: > Could you expand on how you see Delegation being used within an XML > Schema such that an application can take advantage of it in the same > way as it could were the type hierarchy used? > > For example, given the Camera type hierarchy described in your web > page, I could (eventually, come XSLT 2.0) do: > > <xsl:template match="*[type() = 'Camera']"> > ... do some processing common to all cameras ... > </xsl:template> > > How do you see the Delegation pattern helping here? In the design-by-composition approach we have this collection of elements: camera - lens - housing - recording-medium(abstract) ^ | ---------- 35mm or disk or 3x5 etc A stylesheet application can process a camera element by delegating to each subordinate element: <xsl:template match="camera"> <!-- delegate to lens element --> <xsl:apply-templates select="lens"/> <!-- delegate to housing element --> <xsl:apply-templates select="housing"/> <!-- delegate to whatever recording-medium component is present --> <xsl:apply-templates select="*[last()]"/> </xsl:template> As new types of recording-medium components are required we simply drop in a template rule. For example: <xsl:template match="35mm"> ... process 35mm recording-medium ... </xsl:template> <xsl:template match="disk"> ... process disk recording-medium ... </xsl:template> <xsl:template match="3x5"> ... process 3x5 recording-medium ... </xsl:template> All of these recording-medium components have a type that is the same as, or derived from, the recording-medium-type. Thus, if desired, we could have a single template rule for all there recording-medium components: <xsl:template match="*[type() = 'recording-medium-type']"> ... do some processing common to all recording-medium components ... </xsl:template> The important point is that an application can process the camera by delegating to each of its subordinate elements. /Roger
Received on Tuesday, 16 April 2002 10:24:23 UTC