RE: [xsl] Apply-templates - how to omit top level element tags?
Subject: RE: [xsl] Apply-templates - how to omit top level element tags?|
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 07 Sep 2005 19:14:36 -0400
As others have suggested, the canonical approach to handling a given
element in different ways is to qualify your templates with modes.
This isn't the only approach, but it's probably the best path to explore.
At 07:07 PM 9/7/2005, you wrote:
Jay Bryant>> Do you dislike the apply and match scheme (XSLT's native
Good question. Honestly I don't think I currently think that way so I
don't know (such as an English speaker has to translate from German to
be able to understand, whereas a fluent German speaker "thinks" in
German.) It seems fraught with side-effects, however, and it seems hard
to verify that output is "correct" when using that idiom.
It's certainly true that those who are experienced in other kinds of
programming frequently find they have to re-wire their brains to get the
most out of XSLT. (Some have been fortunate to work with other functional
languages and have already done the rewiring; others were never wired
"wrong" to begin with.)
As for the strengths and weaknesses of the paradigm: not only is processing
with templates not fraught with side-effects -- actually side-effects (in
the strict technical sense of having the state of the processor being
altered by the processing as it goes) is precisely what the XSLT paradigm
is designed to *avoid*. So, no side effects. While it is possible to get
around this in XSLT, it's not easy. Yet even this can take getting used to:
like walking on a floor after you're used to walking on tightropes.
You have a much stronger point in asking about the verifiability of the
correctness of your output. Depending on how "correctness" is defined in
given cases, however, it turns out that in practice most stylesheets turn
out to be fairly transparent -- so even when they're difficult to verify
formally, they turn out to be very dependable if constructed properly.
Also, there are often brute-force methods of verification available, such
as validating the output against the schema of your choice (shocking!).
Likewise, this is an area that will be significantly improved by the
schema-aware version of XSLT 2.0 (for those content to use W3C XML Schema).
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