I want make a xslt transformation to xsl-fo but I´m not really sure that I can do this. I try to convert a XML list to a xsl-fo list. Can anyone tell me where can i look for I´m googling for a long time are there aren´t a lot of examples of this. My XML is like this.
<p>TEXT</p>
<ul>
<li>Item1</li>
<li>Item2</li>
</ul>
<p>ANOTHERTEXT</p>
I try use templates for this transformation but my templates don't work to get xsl-fo Can anybody tell me if the templates work in this transformation. If they work can show me an example i can't find anyone. My objetive is get a pdf whit fop
Thanks
This is part of my XML document I recived some parts of the source in HTML and I change HTML to XML now I try convert XML (whit a list) into XSL-FO whit a XSLT. My problem is that I can´t aply templates to this transformation. My final objetive is get a pdf whit FOP.
Thanks
UPDATE
This is my XML:
<Memoria>
<name>TITLE</name>
<Index>INDEX 2010</Index>
<Seccion>
<name>INFORMATION</name>
<Contenido>
<p>TEXT</p>
<ul>
<li>ITEM1</li>
<li>ITEM2</li>
</ul>
<p>ANOTHER</p>
</Contenido>
</Seccion>
</Memoria>
I'm testing your solution Thanks all
If you're having issues with your templates not working, it might be a namespace issue. You should update the question with a more accurate example of your XML.
Here's an example.
XML Input (fixed to be well-formed)
<root>
<p>TEXT</p>
<ul>
<li>Item1</li>
<li>Item2</li>
</ul>
<p>ANOTHERTEXT</p>
</root>
XSLT 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:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/root">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<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>
<xsl:template match="ul">
<fo:list-block padding="4pt">
<xsl:apply-templates/>
</fo:list-block>
</xsl:template>
<xsl:template match="li">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>•</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
</xsl:stylesheet>
XSL-FO output
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page" page-width="8.5in" page-height="11in">
<fo:region-body margin="1in" margin-top="1.5in" margin-bottom="1.5in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>TEXT</fo:block>
<fo:list-block padding="4pt">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>•</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>Item1</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>•</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>Item2</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
<fo:block>ANOTHERTEXT</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Apache FOP output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With