[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] transforming lists


Subject: Re: [xsl] transforming lists
From: ronald heller <ronald@xxxxxxxxxxx>
Date: Wed, 24 Jul 2002 14:40:24 +0200

Hi,

I didn't have time to proper document my example, and maybe it's not exactly what you're after here, but it might give you some ideas as where to look for.
You canjust copy paste the example to any editor (I for one used xml cooktop) for they are complete examples.


Cheers
Ronald

The xml I used:
<document>
<pardef id="9" leftmargin="1.2500in" list="bullet"/>
<pardef id="10" leftmargin="1.2500in" list="hyphen"/>
   <par def="9">
    <run>
     <font size="11pt" name="serif"/>ITEM 1 liste</run>
   </par>
   <par>
    <run>
     <font size="11pt" name="serif"/>ITEM 2 liste</run>
   </par>
   <par>
    <run>
     <font size="11pt" name="serif"/>ITEM 3 liste</run>
    <run>
     <font size="11pt" style="bold" name="Arial" color="blue"/>
     <break/>
    </run>
   </par>
   <par def="10">
    <run>
     <font size="11pt" name="serif"/>ITEM 1 liste</run>
   </par>
   <par>
    <run>
     <font size="11pt" name="serif"/>ITEM 2 liste</run>
   </par>
   <par>
    <run>
     <font size="11pt" name="serif"/>ITEM 3 liste</run>
    <run>
     <font size="11pt" style="bold" name="Arial" color="blue"/>
     <break/>
    </run>
   </par>
</document>

The XSL:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:key name="label" match="pardef" use="@id"/>
<xsl:template match="/">
<!-- standard template-->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="simple" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
<fo:region-body margin-top="0cm" />


<fo:region-before extent="2cm" />

               <fo:region-after extent="1.5cm" />
            </fo:simple-page-master>
         </fo:layout-master-set>


<fo:page-sequence master-reference="simple">


            <fo:flow flow-name="xsl-region-body">
               <xsl:apply-templates />
            </fo:flow>
         </fo:page-sequence>
      </fo:root>
   </xsl:template>

<xsl:template match="par[@def]">
<xsl:variable name="def" select="@def"/>
<fo:list-block>
<xsl:call-template name="list-item">
<xsl:with-param name="def" select="$def"/>
</xsl:call-template>
<xsl:apply-templates select="following-sibling::par[not(@def)]" mode="insert">
<xsl:with-param name="def" select="$def"/>
</xsl:apply-templates>
</fo:list-block>
</xsl:template>


   <xsl:template match="par[not(@def)]" mode="insert">
   <xsl:param name="def"/>
		<xsl:call-template name="list-item">
			<xsl:with-param name="def" select="$def"/>
		</xsl:call-template>
   </xsl:template>

   <xsl:template match="par[not(@def)]">
   </xsl:template>

   <xsl:template name="list-item">
   <xsl:param name="def"/>
         <fo:list-item>
            <fo:list-item-label end-indent="label-end()">
               <fo:block>
                  <fo:inline>
                  <xsl:call-template name="label">
     				<xsl:with-param name="def" select="$def"/>
                  </xsl:call-template>
                  </fo:inline>
               </fo:block>
            </fo:list-item-label>

            <fo:list-item-body start-indent="body-start()">
               <fo:block><xsl:apply-templates select="run"/></fo:block>
            </fo:list-item-body>
         </fo:list-item>
   </xsl:template>

   <xsl:template name="label">
   <xsl:param name="def"/>
   <xsl:choose>
   	<xsl:when test="/document/pardef[@id=$def]/@list='bullet'">*</xsl:when>
 	<xsl:otherwise>-</xsl:otherwise>
   </xsl:choose>
   </xsl:template>
</xsl:stylesheet>


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




Current Thread
Keywords
xml