[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XSLT 1: From flat XML to tree hierarchy XML. Can't seem to find the right way to do it.


Subject: Re: [xsl] XSLT 1: From flat XML to tree hierarchy XML. Can't seem to find the right way to do it.
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 25 May 2006 18:50:19 -0400

At 06:31 PM 5/25/2006, you wrote:
I'd be curious if people on this list
have opinions on whether or not they've come up with rules for when to
use literal result elements and when to use xsl:element.

My $0.02:


Use literal result elements when you can; use xsl:element when you have to.

You have to use xsl:element when:
 * The element name is being generated dynamically
 * You are developing in a framework that doesn't like LREs
   (maybe it's validating the stylesheet against a schema
    with only the xsl elements in it)
 * You are doing something funky involving names and/or namespaces,
   such as stripping namespaces.

... and there may be one or two other reasons.

I find LREs much easier to read and maintain. LREs do have a pedagogical downside, as beginners sometimes interpret them as meaning the processor does "tag writing" (which it doesn't). But the real fix for that is not to avoid them, but simply present a good demonstration of how tag-writing isn't what's happening (for example, showing output of empty HTML elements with output method="xml" vs method="html").

Cheers,
Wendell



======================================================================
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
======================================================================


Current Thread
Keywords