Re: [xsl] problem creating containment during XHTML->XML

Subject: Re: [xsl] problem creating containment during XHTML->XML
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Mon, 23 Feb 2004 23:36:39 +0100
Don Stinchfield wrote:
I'm in the process of breaking up an XHTML file into multiple XML files.
  <heading level="h1"><a name="content" id="content"></a>Overview</heading>
    <p>On February 20, 1865</p>
  <heading level="h3"><a name="mission" id="mission"></a>Mission</heading>
I'm cleaning up a bit and would like to add structure as follows...

    <heading level="h1">Overview</heading>
      <p>On February 20, 1865</p>
    <heading level="h3"></a>Mission</heading>

A kind of grouping problem.

- <xsl:template match="x:heading">
- <section>
- <title>
<xsl:value-of select="." /> </title>
<xsl:apply-templates select="following-sibling::*" />
The above puts me in an infinite loop.

Not necessarily infinite but certainly O(n^2) behaviour. Think about it. Instead of *all* following siblings of a heading, you want to select only siblings whose first preceding header sibling is the matched header. Or in XPath: select="following-sibling::*[ generate-id(preceding-sibling::x:header[1])= generate-id(current())]" There are several other possiblities to express this, some of which may have a better performance.


XSL-List info and archive:

Current Thread