Re: [xsl] normalize-space and sequence

Subject: Re: [xsl] normalize-space and sequence
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 27 Sep 2007 12:23:55 -0400

At 06:43 PM 9/26/2007, you wrote:
David Carlisle wrote:
              <entry ie="{$foobar}" name="{para}"

and apparently want that to be

<entry ie="{normalize-space($foobar)}" name="{normalize-space(para)}"
If there may be multiple para nodes as children of an entry you'll need
string-join as well, if not then not.

that will become messy in the end. I'd opt for the pipeline method (not micro-pipeline, am I correct, Wendell? Because we rerun the whole thing again), where with a couple of extra matching templates, you can focus only on the stripping whitespace bits.

:-) Yep, what Abel showed is a pipeline.

You might also be able to micropipeline this -- that is, pipeline just the nodes you need to preprocess, at the point where they are matched. But micropipelining has a potential weakness, in that when you process a variable derived from a process, you have lost the context of the original process. Sometimes this doesn't matter, and sometimes you can design your micropipeline to account for it -- but I haven't looked at this particular problem well enough to see whether that's an issue.

Heck: a micropipelining approach would look something like:

<xsl:variable name="name-content">
<xsl:apply-templates select="para" mode="normalize-space"/>
<xsl:variable name="ref-content">
<xsl:apply-templates select="following-sibling::entry[1]/para" mode="normalize-space"/>
<entry name="{$name-content}" ref="{$ref-content}" etc... />

Note that you'd still have work to do in your "normalize-space" mode to make sure your whitespace came out properly (as you might want space between the paragraphs as well as trimmed within each paragraph). So it may not be better than XPath-based solutions (depending on your taste).


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
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