Hi I am trying to learn FO, and have started with the IBM developer works Tutorial; http://www-106.ibm.com/developerworks/education/transforming-xml/xmltopdf/index.html the code samples were orginally designed to run under Cocoon 1, but I thought *should* work under 2 as well...
I get the following errors in the log file: INFO (2002-05-03) 13:13.53:964 [cocoon.f] (/cocoon/stepproj/docs/sonnet.pdf) HttpProcessor[8080][3]/FOTreeBuilder: building formatting object tree ERROR (2002-05-03) 13:13.53:964 [cocoon.f] (/cocoon/stepproj/docs/sonnet.pdf) HttpProcessor[8080][3]/FOTreeBuilder: Unknown formatting object http://www.w3.org/1999/XSL/Format^sequence-specification ERROR (2002-05-03) 13:13.53:964 [cocoon.f] (/cocoon/stepproj/docs/sonnet.pdf) HttpProcessor[8080][3]/FOTreeBuilder: Unknown formatting object http://www.w3.org/1999/XSL/Format^sequence-specifier-alternating Any ideas - the sonnet.xml and sonnet.xsl are attached, if anyone has a moment to try this out.. Thanks Derek
<?xml version="1.0"?> <sonnet type="Shakespearean"> <author> <last-name>Shakespeare</last-name> <first-name>William</first-name> <nationality>British</nationality> <year-of-birth>1564</year-of-birth> <year-of-death>1616</year-of-death> </author> <title>Sonnet 130</title> <lines> <line>My mistress' eyes are nothing like the sun,</line> <line>Coral is far more red than her lips red.</line> <line>If snow be white, why then her breasts are dun,</line> <line>If hairs be wires, black wires grow on her head.</line> <line>I have seen roses damasked, red and white,</line> <line>But no such roses see I in her cheeks.</line> <line>And in some perfumes is there more delight</line> <line>Than in the breath that from my mistress reeks.</line> <line>I love to hear her speak, yet well I know</line> <line>That music hath a far more pleasing sound.</line> <line>I grant I never saw a goddess go,</line> <line>My mistress when she walks, treads on the ground.</line> <line>And yet, by Heaven, I think my love as rare</line> <line>As any she belied with false compare.</line> </lines> </sonnet>
<?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"> <!--================================================================--> <!-- Root Element Template --> <!-- This template specifies what creates the root element of the --> <!-- result tree. In this case, it tells the XSL processor to --> <!-- start with the sonnet element. --> <!--================================================================--> <xsl:template match="/"> <xsl:apply-templates select="sonnet"/> </xsl:template> <!--================================================================--> <!-- sonnet template --> <!-- This template takes the sonnet element and processes its --> <!-- contents. --> <!--================================================================--> <xsl:template match="sonnet"> <!--================================================================--> <!-- The fo:root element contains the entire document. --> <!--================================================================--> <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!--================================================================--> <!-- The layout-master-set defines a set of page layouts. For our --> <!-- purposes here, we only need one. --> <!--================================================================--> <fo:layout-master-set> <fo:simple-page-master page-master-name="main" margin-top="75pt" margin-bottom="75pt" margin-left="75pt" margin-right="75pt"> <!--================================================================--> <!-- The region-body element is where all the action is. We'll put --> <!-- all of our content into this space. --> <!--================================================================--> <fo:region-body margin-bottom="75pt"/> </fo:simple-page-master> </fo:layout-master-set> <!--================================================================--> <!-- Our next step is to define the page styles used. We can --> <!-- different page styles for the first page, odd pages, and even --> <!-- pages. They're all the same for this simple document. --> <!--================================================================--> <fo:page-sequence> <fo:sequence-specification> <fo:sequence-specifier-alternating page-master-first="main" page-master-odd="main" page-master-even="main"/> </fo:sequence-specification> <!--================================================================--> <!-- Finally, we'll put everything into a flow element. --> <!--================================================================--> <fo:flow> <xsl:apply-templates select="title"/> <xsl:apply-templates select="author"/> <!--================================================================--> <!-- To get the formatting we want, we'll put the lines of the --> <!-- sonnet into a table. We used this same approach when we --> <!-- transformed a sonnet into HTML. The rhyme scheme indicator --> <!-- goes into the first column, and the line of the sonnet goes in --> <!-- the second. --> <!--================================================================--> <fo:table space-before.optimum="6pt"> <fo:table-column column-width="30pt"/> <fo:table-column column-width="450pt"/> <fo:table-body> <xsl:apply-templates select="lines/line"/> </fo:table-body> </fo:table> </fo:flow> </fo:page-sequence> </fo:root> </xsl:template> <!--================================================================--> <!-- Template for the title element. The title of the sonnet will --> <!-- appear in 24-point type, left aligned (that's what the --> <!-- text-align-last attribute does). Notice that we've made the --> <!-- line-height slightly larger than the font-size; this makes the --> <!-- document much more readable. Without this, the lines of text --> <!-- in our PDF file are all run together. --> <!--================================================================--> <xsl:template match="title"> <fo:block font-size="24pt" line-height="27pt" text-align-last="start" space-before.optimum="24pt"> <xsl:apply-templates/> </fo:block> </xsl:template> <!--================================================================--> <!-- Template for the author element. This is more left-aligned --> <!-- text. We simply pull together the different parts of the --> <!-- original author element to create this subheading. --> <!--================================================================--> <xsl:template match="author"> <fo:block font-size="12pt" line-height="15pt" text-align-last="start" space-before.optimum="12pt"> <xsl:text>Author: </xsl:text> <xsl:apply-templates select="first-name"/> <xsl:text> </xsl:text> <xsl:apply-templates select="last-name"/> <xsl:text> (</xsl:text> <!--================================================================--> <!-- We want the author's nationality, year of birth, and year of --> <!-- death to appear in italics. We use the fo:wrapper element to --> <!-- do this. --> <!--================================================================--> <fo:wrapper font-style="italic"> <xsl:apply-templates select="nationality"/> <xsl:text>, </xsl:text> <xsl:apply-templates select="year-of-birth"/> <xsl:text>-</xsl:text> <xsl:apply-templates select="year-of-death"/> </fo:wrapper> <xsl:text>)</xsl:text> </fo:block> </xsl:template> <!--================================================================--> <!-- Template for the first and third lines of the sonnet. For all --> <!-- of the lines of the sonnet, we'll create a table-row. The --> <!-- first cell contains a letter that indicates the rhyme scheme, --> <!-- while the second cell contains the line of the poem. --> <!--================================================================--> <xsl:template match="line[1]|line[3]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">A</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="green"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the second and fourth lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[2]|line[4]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">B</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="purple"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the fifth and seventh lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[5]|line[7]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">C</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="green"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the sixth and eighth lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[6]|line[8]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">D</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="purple"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the ninth and eleventh lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[9]|line[11]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">E</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="green"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the tenth and twelfth lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[10]|line[12]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">F</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="purple"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> <!--================================================================--> <!-- Template for the last two lines of the sonnet. --> <!--================================================================--> <xsl:template match="line[13]|line[14]"> <fo:table-row space-before.optimum="3pt"> <fo:table-cell> <fo:block font-size="14pt" color="gray">G</fo:block> </fo:table-cell> <fo:table-cell> <fo:block color="green"><xsl:value-of select="."/></fo:block> </fo:table-cell> </fo:table-row> </xsl:template> </xsl:stylesheet>
--------------------------------------------------------------------- Please check that your question has not already been answered in the FAQ before posting. <http://xml.apache.org/cocoon/faqs.html> To unsubscribe, e-mail: <[EMAIL PROTECTED]> For additional commands, e-mail: <[EMAIL PROTECTED]>