[xsl] problem creating containment during XHTML->XML

Subject: [xsl] problem creating containment during XHTML->XML
From: "Don Stinchfield" <des@xxxxxxxx>
Date: Mon, 23 Feb 2004 17:06:50 -0500
Hello,

I'm having a devil of a time trying to create the right node set for my
processing.  Any help would be appreciated. :-)

I'm in the process of breaking up an XHTML file into multiple XML files.
Here's the portion of the input file that's of interest (I've already
Modified the file by replacing HTML headings with a heading tag)...

  [lots of html cruft]
  <heading level="h1"><a name="content" id="content"></a>Overview</heading>
    <p>On February 20, 1865</p>
    <p>Education and related research&#8212; 
    <a href="degre.archi.deans.shtml">Architecture and Planning</a>; 
    <a href="degre.engin.deans.shtml">Engineering</a>;</p>
  <heading level="h3"><a name="mission" id="mission"></a>Mission</heading>
    <p>The mission of </p>
    <p>The Institute is committed to </p>
  <heading level="h3"> <a name="sf" id="sf"></a>Faculty</heading>
    <p> total enrollment is approximately 10,300 students</p>
    <p>The faculty numbers approximately 956</p>
  [lots of html cruft]

I'm cleaning up a bit and would like to add structure as follows...

  <section>
    <heading level="h1">Overview</heading>
      <p>On February 20, 1865</p>
      <p>Education and related research&#8212;   
      <a href="degre.archi.deans.shtml">Architecture and Planning</a>; 
      <a href="degre.engin.deans.shtml">Engineering</a>;</p>
  </section>
  <section>
    <heading level="h3"></a>Mission</heading>
      <p>The mission of </p>
      <p>The Institute is committed to </p>
  </section>
  <section>
    <heading level="h3">Faculty</heading>
      <p> total enrollment is approximately 10,300 students</p>
      <p>The faculty numbers approximately 956</p>
  </section>

In a final phase I'll break the file up.  One xml file per section.

Here's the XSLT file.  I've been working with.

- <xsl:template match="/">
    <xsl:apply-templates select="//x:heading" /> 
  </xsl:template>

- <xsl:template match="x:heading">
  - <section>
  -   <title>
        <xsl:value-of select="." /> 
      </title>
      <xsl:apply-templates select="following-sibling::*" /> 
    </section>
  </xsl:template>

- <xsl:template match="text()|node()|@*">
    <xsl:copy-of select="." /> 
  </xsl:template>

The above puts me in an infinite loop.  I have no idea why.  I've tried
loads of different techniques.  The above seems to be close, but I don't
know how to stop coping nodes that don't belong in a specific section.  I'm
thinking I need to create a nodeset that contains all following siblings up
to but not including the next heading tag.  My gut tells me this should be
easy, but I've been looking at this problem long enough that I'm cross eyed.
Any help would be appreciated.


Regards,
Don Stinchfield
Red Bridge Interactive, Inc.




 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread