[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: decorator / wrapper design pattern
Hi Lucas,
I'm not sure whether this could rightly be said to map to the "decorator" pattern (maybe so), but it seems to me you may be looking for the idiom: <xsl:template match="something"> <xsl:call-template name="some-wrapper"/> </xsl:template> <xsl:template name="some-wrapper"> <xsl:param name="contents"> <xsl:apply-templates/> </xsl:param> <wrapper> <xsl:copy-of select="$contents"/> </wrapper> </xsl:template> this allows you also to do things like <xsl:template match="something-else"> <xsl:call-template name="some-wrapper"> <xsl:with-param select="contents"> <xsl:call-template name="some-other-wrapper"/> </xsl:with-param> </xsl:call-template> </xsl:template> or even <xsl:template match="another-something-else"> <xsl:call-template name="some-wrapper"> <xsl:with-param select="contents"> <xsl:text>Wrap me!</xsl:text> </xsl:with-param> </xsl:call-template> <xsl:apply-templates/> </xsl:template> That is, the "wrapper" (or decorator) template can wrap anything you pass it. A "thick" solution to a nasty problem (map a set of attributes to a set of wrappers) using this idiom (although by matching templates, not calling them by name) appears at But I should also caution you that it isn't very common to have to do this; lighter-weight solutions are usually possible. Also, as Jay says, the requirements this addresses are often better answered by pushing the problem into the next layer up, for example into a CSS stylesheet to be applied to HTML output. Enjoy! Wendell At 08:37 AM 3/18/2005, you wrote: Hi, ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|