Creating additional depth from flat structure using XSLT

Subject: Creating additional depth from flat structure using XSLT
From: "Ed Nixon" <ed.nixon@xxxxxxxxxxxxxxxxx>
Date: Wed, 5 Apr 2000 13:52:36 -0400
This is a follow-up to an earlier question on concatenating content in a
sequence of like-named tags.

The task here is to create enclosing levels around a series of more-or-less
sibling elements. Here is a snippet (long),again from Rick Geimer's RTF2XML:

<p stylename="heading1" >
  <string>More Money for All Amendment
  </string>
</p>
<p stylename="section">
  <string>1.(1)Clause 8 (1) (a) of the</string>
  <string italic="on">More Money for All Amendment</string>
  <string> is deleted and the following substituted:</string>
</p>
<p stylename="clause">
  <string>(a)the entrepreneur or, if there is more than one entrepreneur,
one or more of the entrepreneurs.
  </string>
</p>
<p stylename="subsection">
  <string>(2)Subsection 8(1) of the Amendment is amended by striking out
'or' at the end of clause (e), by adding 'or' at the end of clause (f) and
by adding the following clause:
  </string>
</p>
<p stylename="clause">
  <string>(g)a person appointed as administrator by the Boss under section
71.
  </string>
</p>
<p stylename="section">
  <string>2. Subsection 9 (1) of the Act is repealed and the following
substituted:
  </string>
</p>
<p stylename="subsection">
  <string>(1) Within the prescribed period of time, the administrator of a
entrepreneurial venture shall apply to the Boss for registration of the
case.
  </string>
</p>
<p stylename="section">
  <string>3.(1) Clause 29 (1) (e) of the Amendment is repealed.
  </string>
</p>
<p stylename="subsection">
  <string>(2)Subsection 29 (1) of the Amendment is amended by adding the
following clauses:
  </string>
</p>
<p stylename="clause">
  <string>(g)an entrepreneur;
  </string>
</p>
<p stylename="clause">
  <string>(h)a person required to make contributions according to the sweat
of his brow on behalf of other folks;
  </string>
</p>
<p stylename="clause">
  <string>(i)an agent of a person described in any of clauses (a) to (h) who
is authorized in writing; or
  </string>
</p>
<p stylename="clause">
  <string>(j)such other persons as may be prescribed.
  </string>
</p>

Apologies for the length of the snippet. However, it seemed necessary to
capture the sense of the problem. I've removed what I think are most of the
unnecessary attributes from the 'p' and 'string' tags to try for clarity.

The idea is to try to wrap the 'p' elements into a hierarchy based on the
value of the 'stylename' attribute. The output *might* have the following
structure:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE amendment [
<!ELEMENT amendment  (heading1,(section | clause*)*)* >
<!ELEMENT heading1  (#PCDATA) >
<!ELEMENT section  (clause* | subsection*)* >
<!ELEMENT clause  (para+) >
<!ELEMENT subsection  (clause*) >
<!ELEMENT para  (#PCDATA) >
]>

I suspect most of you get paid real money for information about this kind of
thing. None-the-less, I'd be grateful for any pointers, suggestions or
snippets you have time to contribute.

Many thanks in advance for your help. Regards.             ...edN



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


Current Thread