AW: AW: [Wyonacms-users] Fo in 5 steps

"Scherler, Thorsten" <[email protected]> Tue, 29 Oct 2002 10:15:17 +0100
Newsgroups gmane.comp.cms.wyona.devel,gmane.comp.cms.wyona.user
Message-ID <[email protected]>
Hello group,

I forgotten to attach the doc2xml.xsl.

Here it is:

<?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:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <fo:layout-master-set>

        <fo:simple-page-master master-name="A4"
           page-width="210mm"  page-height="297mm"
           margin-top="0.5in"  margin-bottom="0.5in"
           margin-left="0.5in" margin-right="0.5in">
          <fo:region-before extent="1.0in"/>
          <fo:region-body margin-top="1.0in"
                          margin-bottom="1.0in"/>
          <fo:region-after  extent="1.0in"/>
        </fo:simple-page-master>

      </fo:layout-master-set>

      <fo:page-sequence master-reference="A4"
        initial-page-number="1" language="en" country="us">

        <fo:static-content flow-name="xsl-region-before">
          <fo:block>Weidmüller Telefonmarketing</fo:block>
                    <fo:block><fo:leader leader-pattern="rule"
                               leader-length="18cm" />
          </fo:block>
        </fo:static-content>

        <fo:static-content flow-name="xsl-region-after">
          <fo:block><fo:leader leader-pattern="rule"
                               leader-length="18cm" />
          </fo:block>
          <fo:block>Seite <fo:page-number/></fo:block>
        </fo:static-content>

        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates/>
        </fo:flow>

      </fo:page-sequence>

    </fo:root>
  </xsl:template>
	<xsl:template match="p">
		<fo:block>
			<xsl:apply-templates/>
		</fo:block>
	</xsl:template>
	<!-- convert sections to XSL-FO headings -->
	<xsl:template match="s1">
		<fo:block font-size="24pt" color="red" font-weight="bold">
			<xsl:apply-templates select="@title"/>
		</fo:block>
		<xsl:apply-templates/>
	</xsl:template>
		<xsl:template name="Records">
		<xsl:for-each select="database/table0/record0">
			<tr bgcolor="#ffff00">
				<td>Datensatz</td>
				<td width="5">&#160;</td>
				<td align="right">
					<xsl:value-of select="position()"/>
				</td>
			</tr>
			<tr bgcolor="#00FFFF">
				<td>Feldname</td>
				<td width="5">&#160;</td>
				<td>Ausprägung</td>
			</tr>
			<xsl:call-template name="RecordSet"/>
			<tr>
				<td height="10">&#160;</td>
				<td width="5">&#160;</td>
				<td/>
			</tr>
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="RecordSet">
		<xsl:for-each select="*">
			<xsl:choose>
				<xsl:when test="position() mod 2 = 1">
					<tr bgcolor="lightgrey">
						<td>
							<xsl:value-of select="name(.)"/>
						</td>
						<td width="5">&#160;</td>
						<td>
							<xsl:variable name="boolean">
								<xsl:value-of select="."/>
							</xsl:variable>
							<xsl:choose>
								<xsl:when test="$boolean='False'">
									<input type="checkbox"/>
								</xsl:when>
								<xsl:when test="$boolean='True'">
									<input type="checkbox" checked="checked"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$boolean"/>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
				</xsl:when>
				<xsl:otherwise>
					<tr bgcolor="white">
						<td>
							<xsl:value-of select="name(.)"/>
						</td>
						<td width="5">&#160;</td>
						<td>
							<xsl:variable name="boolean">
								<xsl:value-of select="."/>
							</xsl:variable>
							<xsl:choose>
								<xsl:when test="$boolean='False'">
									<input type="checkbox"/>
								</xsl:when>
								<xsl:when test="$boolean='True'">
									<input type="checkbox" checked="checked"/>
								</xsl:when>
								<xsl:otherwise>
									<xsl:value-of select="$boolean"/>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:for-each>
	</xsl:template>

</xsl:stylesheet>

-----Ursprüngliche Nachricht-----
Von: Scherler, Thorsten 
Gesendet: Montag, 28. Oktober 2002 15:38
An: Wyonacms-Users (E-Mail); Wyona-Dev (E-Mail)
Betreff: [Wyonacms-dev] AW: [Wyonacms-users] Fo in 5 steps


Hello group,

I've just modified the doc2xml.xsl.

Now there is a nice header and footer. The one before wasn't that nice I have to admit!

In my department I will create the report (formally in MS access) with wyona.

Basiclly the idea is to have a query on a db, transform the data with xsl and create a pdf.

If you keen to know how it works drop me a mail and I will post the steps to the mailinglist!


-----Ursprüngliche Nachricht-----
Von: Scherler, Thorsten 
Gesendet: Montag, 28. Oktober 2002 13:49
An: [email protected]
Betreff: [Wyonacms-users] Fo in 5 steps


Hello group,

I have noticed that where some discussion about FO.

Here is an easy way to implemend fo within Wyona.

1) in the sitemap (live or authoring)
find: 	<map:components>
add:	<map:serializer name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2pdf" mime-type="application/pdf"/>
		</map:serializers>

2) within the same sitemap:
find: 	<!-- =========================== Pipelines ================================ -->
	<map:pipelines>
		<map:pipeline>
add: 			<map:match pattern="*.pdf">
				<map:generate src="docs/publication/{1}.xml"/>
				<map:transform src="stylesheets/publication/wd/pdf/doc2pdf.xsl"/>
				<map:serialize type="fo2pdf"/>
			</map:match>
3) the doc2pdf.xsl should look like this (more information @ http://www.ibiblio.org/xml/books/bible/updates/15.html):
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- edited with XMLSPY v5 U (http://www.xmlspy.com) by eric cartman (sp int) -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<!-- generate PDF page structure -->
	<xsl:template match="/">
		<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
			<fo:layout-master-set>
				<fo:simple-page-master master-name="page" page-height="29.7cm" page-width="21cm" margin-top="1cm" margin-bottom="2cm" margin-left="2.5cm" margin-right="2.5cm">
					<fo:region-before extent="2cm"/>
					<fo:region-body margin-top="3cm"/>
					<fo:region-after extent="1.5cm"/>
				</fo:simple-page-master>
				<fo:page-sequence-master master-name="all">
					<fo:repeatable-page-master-alternatives>
						<fo:conditional-page-master-reference master-reference="page" page-position="first"/>
					</fo:repeatable-page-master-alternatives>
				</fo:page-sequence-master>
			</fo:layout-master-set>
			<fo:page-sequence master-reference="all">
				<fo:flow flow-name="xsl-region-body">
					<fo:block>
						<fo:list-item-label>
							<fo:block text-align="start" font-weight="bold">Weidmüller Telefonmarketing</fo:block>
						</fo:list-item-label>
						<fo:block>
							<fo:leader leader-pattern="rule" rule-thickness="2pt"/>
						</fo:block>
						<xsl:apply-templates/>
					</fo:block>
					<fo:block text-align="start" font-weight="bold">
  ©  <fo:basic-link external-destination="url(http://www.WEIDMUELLER.com/)" color="#0000C0" text-decoration="underline">
  Weidmueller
  <fo:wrapper font-weight="bold" color="#000000"/>
						</fo:basic-link>
  2002/2003 
  </fo:block>
					<fo:block text-align="end">Seite:  <fo:page-number/>
					</fo:block>
				</fo:flow>
			</fo:page-sequence>
		</fo:root>
	</xsl:template>
	<!-- process paragraphs -->
	<xsl:template match="p">
		<fo:block>
			<xsl:apply-templates/>
		</fo:block>
	</xsl:template>
	<!-- convert sections to XSL-FO headings -->
	<xsl:template match="s1">
		<fo:block font-size="24pt" color="red" font-weight="bold">
			<xsl:apply-templates select="@title"/>
		</fo:block>
		<xsl:apply-templates/>
	</xsl:template>
</xsl:stylesheet>

4.) example doc.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<page>
	<title>This is the pageOne.xml example</title>
	<s1 title="Section one">
		<p>This is the text of section one</p>
		<p>This is the text od Weidmueller</p>
	</s1>
</page>

5.) go to http://localhost:8088/wyona-cms/weidmueller/doc.pdf
where weidmueller is the dir where the *.xml is.


> Mit freundlichem Gruss,
> 
> Thorsten Scherler
> Marketing / Telefonmarketing
> 
> Weidmüller GmbH & Co.
> P.O. Box 2807
> 33058 Paderborn
> Tel.:+ 49 - 5252-960-350
> Fax:+ 49 - 5252-960-116
> eMail: [email protected]
> http://www.weidmueller.de
> 
> 

_______________________________________________
WyonaCMS-users mailing list
[email protected]
http://mail.wyona.org/cgi-bin/mailman/listinfo/wyonacms-users

_______________________________________________
WyonaCMS-dev mailing list
[email protected]
http://mail.wyona.org/cgi-bin/mailman/listinfo/wyonacms-dev