Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question reg XSL-FO

Status
Not open for further replies.

munnanext

Programmer
Aug 20, 2004
49
US
Hi Everyone,

I am new to XML, XSLT and XSL-FO and i am learning it. I need to generate a pdf document for an xml. I have written xsl file for my xml document, and i have used<fo:table> tags in my xsl file. When i am executing the code through java, i am able to generate the pdf document, but it is not printing any thing. I have just a blank pdf document.

Here I am sending my xml and xsl files, which can better explain my problem

My XML file is:
Code:
<?xml version="1.0" ?>
<details>
<Family>
<name>Suresh</name>
<age>30</age>
<gender>Male</gender>
</Family>
<Family>
<name>Nitin</name>
<age>38</age>
<gender>Male</gender>
</Family>
</details>
And my XSL file is
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/Xsl/Format">[/URL]

	<xsl:template match="/">
 
 <fo:root xmlns:fo="[URL unfurl="true"]http://www.w3.org/1999/XSL/Format">[/URL]
 
   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
                   page-height="29.7in" 
                   page-width="21in"
                   margin-top="1in" 
                   margin-bottom="2in" 
                   margin-left="2.5in" 
                   margin-right="2.5in">
       <fo:region-body margin-top="3in"/>
       <fo:region-before extent="3in"/>
       <fo:region-after extent="1.5in"/>
     </fo:simple-page-master>
   </fo:layout-master-set>
   <fo:page-sequence master-reference="simple">
   	<fo:flow flow-name="xsl-region-body">
   	       <xsl:apply-templates select="details"/>
   	</fo:flow>
   </fo:page-sequence>
  </fo:root> 
 </xsl:template>
	<xsl:template match="details">
		<fo:block>
			<xsl:apply-templates select="Family"/>
		</fo:block>
	</xsl:template>
	<xsl:template match="Family">
		<fo:table-and-caption>
		<fo:table>
		<fo:table-column column-width="25mm"/>
		<fo:table-column column-width="25mm"/>
		<fo:table-header>
		  <fo:table-row>
		    <fo:table-cell>
		      <fo:block font-weight="bold">Name</fo:block>
		    </fo:table-cell>
		    <fo:table-cell>
		      <fo:block font-weight="bold">Age</fo:block>
		    </fo:table-cell>
		    <fo:table-cell>
		      <fo:block font-weight="bold">Gender</fo:block>
		    </fo:table-cell>
		  </fo:table-row>
		</fo:table-header>
		<fo:table-body>
		  <fo:table-row>
		    <fo:table-cell>
		      <fo:block><xsl:value-of select="name"/> </fo:block>
		    </fo:table-cell>
		    <fo:table-cell>
		      <fo:block><xsl:value-of select="age"/> </fo:block>
		    </fo:table-cell>
		    <fo:table-cell>
		      <fo:block><xsl:value-of select="gender"/> </fo:block>
		    </fo:table-cell>
		  </fo:table-row>
		</fo:table-body>
		</fo:table>
		</fo:table-and-caption>
	</xsl:template>
	
</xsl:stylesheet>

Any Help would be greatly appreaciated

Thanks in Advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top