Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL: Creating HTML bullet lists

Status
Not open for further replies.

Kenny100

Technical User
Feb 6, 2001
72
NZ
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=&quot;a&quot;>
<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=&quot;a&quot;>
<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=&quot;Clause&quot;>
<ol>
<xsl:apply-templates select=&quot;Req&quot; />
</ol>
</xsl:template>

<xsl:template match=&quot;Req&quot;>
<li class=&quot;req&quot;><xsl:apply-templates select=&quot;para&quot; />
<xsl:choose>
<xsl:when test=&quot;count(child::SubReq)!=0&quot;>
<ol type=&quot;a&quot;>
<xsl:apply-templates select=&quot;SubReq&quot; />
</ol>
</xsl:when>
</xsl:choose>
</li>
</xsl:template>

<xsl:template match=&quot;SubReq&quot;>
<li class=&quot;subreq&quot;><xsl:apply-templates select=&quot;para&quot; /></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=&quot;a&quot;>
<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
 
Get rid of your
<xsl:apply-templates select=ZZZZ/>
and replace with
<xsl:apply-templates/>

then put the <ol> tags inside the subreq template
rather than in the req template.

What's happening is that the <ol> being wrapped around the para as well and each para should presumably be inside its own <p>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top