Page 1 of 1

how to display the element attribute values (xml to pdf)

Posted: Wed Jan 18, 2006 9:59 am
This is my xml file like this
<emp name="jana" id="1228"></emp>

Iam converting xml file into pdf using FOP.

i need output like this:

name : jana
id : 1228

how to modify the xsl file.... please give the solution as soon as possible

Posted: Wed Jan 18, 2006 10:55 am
by Radu
Hello Jana

For an xml file like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<emp name="name1" id="1228"></emp>
<emp name="name2" id="1229"></emp>
The stylesheet could be something like:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
<xsl:template match="/">
<fo:root xmlns:fo="">
<fo:simple-page-master master-name="all-pages">
<fo:region-body region-name="xsl-region-body" margin="0.7in" column-gap="0.25in"
border="0.25pt solid gray" padding="6pt"/>
<fo:page-sequence master-reference="all-pages">
<fo:flow flow-name="xsl-region-body">
<xsl:for-each select="//emp">
name: <xsl:value-of select="@name"/>
id: <xsl:value-of select="@id"/>
You have to create a scenario and apply the stylesheet over the xml file with fo-processing and save the result as pdf.

For more information about fo you can read this tutorial: and also check out the fo samples that come with Oxygen located in the samples/fo folder of the installation directory.

Regards, Radu