[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Type-based design patterns


type based design
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

/ Jeni Tennison <jeni@j...> was heard to say:
[...]
| I agree with this, very much. Actually I think we can break this
| pattern down into two classes:
|
|   1. grouping elements based on their *content* -- in other words, the
|      *type* hierarchy
|
|   2. grouping elements based on their *context* -- in other words, the
|      *substitution group* hierarchy
|
| An example of 1 is dealing with all addresses in the same way, whether
| the element that holds the address is a <buyerAddr> or <supplierAddr>
| element.
|
| An example of 2 is dealing with all block-level elements in the same
| way, whether they're paragraphs, tables or lists (all of which have
| very different content).

As I consider the design of an XML Schema for DocBook, I wonder if I
need to be thinking more explicitly in terms of supporting 2 by
having, for example, all the list elements in the same substitution
group. I'm more inclined to use model groups, but maybe that's just
old design patterns.

As I think about 2 though, I'm struck that I'm going to need the
equivalent of "next-match" in order for it to be useful.

<xsl:template match="~ListType">
  <!-- some general stuff about all lists -->
  <xsl:next-match/>
  <!-- some general stuff about all lists -->
</xsl:template>

<xsl:template match="orderedlist">
  <!-- some stuff about ordered lists -->
</xsl:template>

I'm not going to feel like I got much benefit out of the type-based
matching if I have to write:

<xsl:template match="~ListType">
  <!-- some general stuff about all lists -->
  <xsl:choose>
    <xsl:when test="local-name(.) = 'orderedlist'">
    </xsl:when>
    <xsl:when test="local-name(.) = 'itemizedlist'">
    </xsl:when>
    <!-- ... -->
  </xsl:choose>
  <!-- some general stuff about all lists -->
</xsl:template>

                                        Be seeing you,
                                          norm

- -- 
Norman.Walsh@S...    | Nothing will ever be attempted, if all
XML Standards Architect | possible objections must be first
Sun Microsystems, Inc.  | overcome.--Dr. Johnson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.7 <http://mailcrypt.sourceforge.net/>

iD8DBQE9m1pHOyltUcwYWjsRAhBfAJ9Yuta4LWSaPqZFKglBGC8X5RyWjACgoa/2
Maxlo1SUCV0QZ9kOdSuCQ2E=
=01+g
-----END PGP SIGNATURE-----

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.