I'm a beginner at XSL FO. I have a very simple XML document :
<?xml version= "1.0" ?>
<test>
TEST
</test>
I would like to print the content between the tag <test>
I wrote the following XLS FO document to be processed by FOP.
<fo:root xmlns:yt="http://www开发者_如何学C.yseop.com/text/2"
xmlns:y="http://www.yseop.com/engine/3"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<fo:layout-master-set>
<fo:simple-page-master master-name="rapport">
<fo:region-body margin-top="0.75in" margin-left="0.75in" margin-right="0.75in" margin-bottom="0.75in"/>
<fo:region-after extent="0.25in"/>
<fo:region-start/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="rapport">
<fo:flow flow-name="xsl-region-body">
<fo:block>
XXX
<xsl:apply-templates select="document('D:\XXX-conseilVente\xmlBatch\input_test1.xml')/test"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
I get the following warning :
[fop] 25 mai 2011 12:05:10 org.apache.fop.events.LoggingEventListener processEvent
[fop] ATTENTION: Unknown formatting object "{http://www.w3.org/1999/XSL/Transform}apply-templates" encountered (a child of fo:block}. (See position 22:99)
and there is nothing on my output pdf.
I guess I am not using the right function to parse the document with xsl-t
Can you tell me what function to use?
Thanks in advance
XSLT and XSL-FO are two separate languages. Basically, it works the other way round, than what you do at the moment: The FO is embedded in an XSLT stylesheet, which is then used to process the original XML to create an XSL-FO document (without any XSLT). That is thrown at the XSL-FO processor to create, e.g., PDF.
XSLT processing
| |
XML ---> XSL-FO ---> PDF
So you start with a XSLT stylesheet like this (no namespaces and such, just to give you an idea):
<xslt:stylesheet>
<xslt:template match="/">
<fo:root>
<!-- fo head -->
<fo:page-sequence>
<fo:flow>
<xslt:apply-templates /> <!-- process the rest of the doc-->
</fo:flow>
</fo:page-sequence>
</fo:root>
</xslt:template>
<xslt:template match="test">
<fo:block>
<xslt:value-of select="." />
</fo:block>
</xslt:template>
</xslt:stylesheet>
You can find many questions ansered at Dave Pawson's XSL FAQ.
精彩评论