This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

indenting text with <dl> and <dd> hack


I am trying to use the <dl> and <dd> hack to generated indented
html. This is my xml:

<indent>
 <a>Item1.0</a>
 <a>Item1.1</a>
 <a>Item1.2
  <a>Item1.2.1</a>
  <a>Item1.2.2</a>
  <a>Item1.2.3</a>
 </a>
 <a>Item1.3</a>
 <a>Item1.4
  <a>Item1.4.1</a>
  <a>Item1.4.2</a>
 </a>
</indent>

This is what I want as html output:

<dl>
 <dd>Item1.0</dd>
 <dd>Item1.1</dd>
 <dd>Item1.2</dd>
 <dl>
  <dd>Item1.2.1</dd>
  <dd>Item1.2.2</dd>
  <dd>Item1.2.3</dd>
 </dl>
 <dd>Item1.3</dd>
 <dd>Item1.4</dd>
 <dl>
  <dd>Item1.4.1</dd>
  <dd>Item1.4.2</dd>
 </dl>
</dl>

I am having a problem in the early placement of the end tags </dl>. 
Here is the template I have been working with:

<xsl:template match="a">
 <xsl:choose>
  <xsl:when test="count(preceding-sibling::*)=0">
   <dl>
    <dd>
     <xsl:value-of select="text()"/>
    </dd>
    <xsl:apply-templates select="a"/>
   </dl>
  </xsl:when>
  <xsl:otherwise>
   <dd>
    <xsl:value-of select="text()"/>
   </dd>
   <xsl:apply-templates select="a"/>
  </xsl:otherwise>
 </xsl:choose>
</xsl:template>

Any help would be appreciated.

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]