Hi Folks
I'm trying to use XSL to transform the following XML into HTML:
*** XML Fragment ***
<Clause>
<Req>
<para>Introductory text for bullet list 1:</para>
<SubReq><para>List 1: Bullet 1</para></SubReq>
<SubReq><para>List 1: Bullet 2</para></SubReq>
<SubReq><para>List 1: Bullet 3</para></SubReq>
<para>More text and introduction to bullet list 2:</para>
<SubReq><para>List 2: Bullet 1</para></SubReq>
<SubReq><para>List 2: Bullet 2</para></SubReq>
<SubReq><para>List 2: Bullet 3</para></SubReq>
</Req>
</Clause>
*** The HTML needs to be something like this: ***
<p>Introductory text for bullet list 1:
<ol type="a">
<li>List 1: Bullet 1</li>
<li>List 1: Bullet 2</li>
<li>List 1: Bullet 3</li>
</ol>
More text and introduction to bullet list 2:
<ol type="a">
<li>List 2: Bullet 1</li>
<li>List 2: Bullet 2</li>
<li>List 2: Bullet 3</li>
</ol>
</p>
*** Currently, my XSL looks like this: ***
<xsl:template match="Clause">
<ol>
<xsl:apply-templates select="Req" />
</ol>
</xsl:template>
<xsl:template match="Req">
<li class="req"><xsl:apply-templates select="para" />
<xsl:choose>
<xsl:when test="count(child::SubReq)!=0">
<ol type="a">
<xsl:apply-templates select="SubReq" />
</ol>
</xsl:when>
</xsl:choose>
</li>
</xsl:template>
<xsl:template match="SubReq">
<li class="subreq"><xsl:apply-templates select="para" /></li>
</xsl:template>
*** The Problem ***
Instead of the HTML that I would like (see above) I keep getting a layout like this:
<p>Introductory text for bullet list 1:More text and introduction to bullet list 2:
<ol type="a">
<li>List 1: Bullet 1</li>
<li>List 1: Bullet 2</li>
<li>List 1: Bullet 3</li>
<li>List 1: Bullet 4</li>
<li>List 1: Bullet 5</li>
<li>List 1: Bullet 6</li>
</ol>
</p>
In other words, the introductory paragraphs for each bullet list (<Req/para>) get bundled together followed by all of the <SubReq/para> nodes in a single list.
I think that what I'm trying to do is fairly standard i.e. a single paragraph containing multiple bulleted lists. Does anyone know what I'm doing wrong?
Cheers,
Fiddler
I'm trying to use XSL to transform the following XML into HTML:
*** XML Fragment ***
<Clause>
<Req>
<para>Introductory text for bullet list 1:</para>
<SubReq><para>List 1: Bullet 1</para></SubReq>
<SubReq><para>List 1: Bullet 2</para></SubReq>
<SubReq><para>List 1: Bullet 3</para></SubReq>
<para>More text and introduction to bullet list 2:</para>
<SubReq><para>List 2: Bullet 1</para></SubReq>
<SubReq><para>List 2: Bullet 2</para></SubReq>
<SubReq><para>List 2: Bullet 3</para></SubReq>
</Req>
</Clause>
*** The HTML needs to be something like this: ***
<p>Introductory text for bullet list 1:
<ol type="a">
<li>List 1: Bullet 1</li>
<li>List 1: Bullet 2</li>
<li>List 1: Bullet 3</li>
</ol>
More text and introduction to bullet list 2:
<ol type="a">
<li>List 2: Bullet 1</li>
<li>List 2: Bullet 2</li>
<li>List 2: Bullet 3</li>
</ol>
</p>
*** Currently, my XSL looks like this: ***
<xsl:template match="Clause">
<ol>
<xsl:apply-templates select="Req" />
</ol>
</xsl:template>
<xsl:template match="Req">
<li class="req"><xsl:apply-templates select="para" />
<xsl:choose>
<xsl:when test="count(child::SubReq)!=0">
<ol type="a">
<xsl:apply-templates select="SubReq" />
</ol>
</xsl:when>
</xsl:choose>
</li>
</xsl:template>
<xsl:template match="SubReq">
<li class="subreq"><xsl:apply-templates select="para" /></li>
</xsl:template>
*** The Problem ***
Instead of the HTML that I would like (see above) I keep getting a layout like this:
<p>Introductory text for bullet list 1:More text and introduction to bullet list 2:
<ol type="a">
<li>List 1: Bullet 1</li>
<li>List 1: Bullet 2</li>
<li>List 1: Bullet 3</li>
<li>List 1: Bullet 4</li>
<li>List 1: Bullet 5</li>
<li>List 1: Bullet 6</li>
</ol>
</p>
In other words, the introductory paragraphs for each bullet list (<Req/para>) get bundled together followed by all of the <SubReq/para> nodes in a single list.
I think that what I'm trying to do is fairly standard i.e. a single paragraph containing multiple bulleted lists. Does anyone know what I'm doing wrong?
Cheers,
Fiddler