Subject: Re: [xsl] unordered lists from xml to html From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 28 Apr 2002 21:07:34 -0400 |
You will see that the attributes in the para element determine whether the paragraph should be in a bullet or not.
t:\ftemp>type ian.xml <?xml version="1.0" encoding="iso-8859-1"?> <summary> <para bullet="1">This is paragraph 1 </para> <para bullet="0">This is paragraph 2 </para> <para bullet="1">This is paragraph 3 </para> <para bullet="1">This is paragraph 4 </para> </summary> t:\ftemp>type ian.xsl <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="summary"> <xsl:apply-templates select="para[1]"/><!--walk through one at a time--> </xsl:template>
<xsl:template match="para"><!--either standalone or first of a group--> <xsl:choose> <xsl:when test="@bullet='1'"><!--first of a group--> <ul> <xsl:apply-templates select="." mode="in-a-group-of-siblings"/> </ul> <!--skip all those in the group and start at the next standalone--> <xsl:apply-templates select="following-sibling::para[@bullet='0'][1]"/> </xsl:when> <xsl:otherwise><!--standalone--> <p><xsl:value-of select="."/></p> <xsl:apply-templates select="following-sibling::para[1]"/><!--next--> </xsl:otherwise> </xsl:choose> </xsl:template>
<xsl:template match="para" mode="in-a-group-of-siblings"> <li><xsl:value-of select="."/></li> <!--only continue if the next one belongs in the group--> <xsl:apply-templates select="following-sibling::para[1][@bullet='1']" mode="in-a-group-of-siblings"/> </xsl:template>
t:\ftemp>xt ian.xml ian.xsl <?xml version="1.0" encoding="utf-8"?> <ul> <li>This is paragraph 1 </li> </ul> <p>This is paragraph 2 </p> <ul> <li>This is paragraph 3 </li> <li>This is paragraph 4 </li> </ul>
t:\ftemp> t:\ftemp>xt ian.xml ian.xsl <?xml version="1.0" encoding="utf-8"?> <ul> <li>This is paragraph 1 </li> </ul> <p>This is paragraph 2 </p> <ul> <li>This is paragraph 3 </li> <li>This is paragraph 4 </li> </ul>
-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO: June 17-21, 2002 - : 3-days XML Information Modeling: July 31-August 2, 2002
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-07-1 Practical Formatting Using XSLFO XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed), articles, training(instructor-live,Internet-live,web/CD,licensed) Next public training: 2002-05-06,07,09,10,13,20, - 06-04,07,10,11,13,14,17,20,07-31,08-05
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] unordered lists from xml , Michael Kay | Thread | [xsl] Somewhat Comlex XSL matching , Derek Doerr |
Re: [xsl] Somewhat Comlex XSL match, G. Ken Holman | Date | [xsl] XSL tags in IE5 * , browser p, Suman . Sathyanaraya |
Month |