[Home] [By Thread] [By Date] [Recent Entries]
At 2009-04-12 16:09 +0000, LiuKui wrote:
I began to study XSL 2 weeks ago, now I don't understand how to integrate XSLT tags with FO tags in a single .xsl file. For example: Your stylesheet is a complete stylesheet (with errors), but it is not creating a complete XSL-FO result. <?xml version="1.0" encoding="UTF-8"?> Note that you are using the wrong namespaces. Change "w3c" to "w3" in the above namespaces. <xsl:template match="person"> <fo:block border="thick silver ridge"> <xsl:value-of select="@last-name"/> <xsl:text> </xsl:text> <xsl:value-of select="@first-name"/> </fo:block> </xsl:template> </xsl:stylesheet> Correct, because unlike HTML in browsers, you cannot simply throw "tag soup" at an XSL-FO engine and expect blocks to be displayed. You need to have the proper document element <fo:root>, and then you need to specify the page geometry. For example, here is a stylesheet that creates a more complete XSL-FO result: <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 font-family="Times" font-size="20pt"> <fo:layout-master-set>
<fo:simple-page-master master-name="frame"
page-width="210mm" page-height="297mm"
margin-top="1cm" margin-bottom="1cm"
margin-left="1cm" margin-right="1cm">
<fo:region-body region-name="frame-body"/>
</fo:simple-page-master>
</fo:layout-master-set> <fo:page-sequence master-reference="frame">
<fo:flow flow-name="frame-body">
<xsl:apply-templates/>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template><xsl:template match="person"> <fo:block border="thick silver ridge"> <xsl:value-of select="@last-name"/> <xsl:text> </xsl:text> <xsl:value-of select="@first-name"/> </fo:block> </xsl:template> </xsl:stylesheet> and <fo:foot> tag doesn't coexist with <xsl:stylesheet> tag. There is no element <fo:foot> in the XSL-FO vocabulary. Perhaps you meant to type <fo:root>. What's more, I find that Windows IE fails to recognise .fo file, which makes me a little confused. Internet Explorer is an HTML browser and not an XSL-FO engine. It does not recognize the XSL-FO vocabulary. It only recognizes the HTML vocabulary. Could anyone be so kind as to explain these problems to me? I hope this helps. I suggest you find some instruction somewhere in a book or course in order to learn foundation basics. . . . . . . . . . . . . Ken p.s. for those in North America, I'm teaching the foundations of XSL-FO and an overview of every formatting object in the upcoming 3-day hands-on training in the Los Angeles area in June 2009; it is preceded by 5-day hands-on training for XSLT and XQuery the week before.
|

Cart



