Hi,
I had  a look at the post created on Camel and FOP by Bilgin Ibryam  on Nov 4, 
2011 at 12:20 pm <http://grokbase.com/g/camel/dev/2011/11> ,but did not find 
any sample code.
I have followed the instructions given in the post and created the below files.

XML

<?xml version="1.0" encoding="UTF-8"?>
<Employees>
        <Employee>
                <Name>PG /Name>
                <Occupation>Sr. Developer</Occupation>
                <Email>p...@dwp.com</Email>
        </Employee>

        <Employee>
                <Name>SM </Name>
                <Occupation>Manager</Occupation>
                <Email>s...@dwp.com</Email>
        </Employee>

        <Employee>
                <Name>NJ</Name>
                <Occupation>Tech Lead</Occupation>
                <Email>n...@dwp.com</Email>
        </Employee>

        <Employee>
                <Name>DH /Name>
                <Occupation>Sr. Developer</Occupation>
                <Email>d...@dwp.com</Email>
        </Employee>
</Employees>
--------------
XSL

<xsl:stylesheet version="1.1"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";> 
                                <!--  
xmlns:xsl="http://www.w3.org/1999/XSL/Format";
                                exclude-result-prefixes="xsl"-->
 
        <xsl:template match="/">
                  <xsl:root xmlns:xsl="http://www.w3.org/1999/XSL/Format";>

      <xsl:layout-master-set>
        <xsl:simple-page-master master-name="simpleA4" page-height="29.7cm" 
page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" 
margin-right="2cm">
          <xsl:region-body/>
        </xsl:simple-page-master>
      </xsl:layout-master-set>
      <xsl:page-sequence master-reference="simpleA4">
        <xsl:flow flow-name="xsl-region-body">
          <xsl:block xslnt-size="20pt" xslnt-weight="bold" 
space-after="5mm">Employees List: <xsl:value-of select="Employees"/>
          </xsl:block>
          <xsl:block xslnt-size="10pt">
            <xsl:table table-layout="fixed" width="100%" 
border-collapse="separate">
              <xsl:table-column column-width="8cm"/>
              <xsl:table-column column-width="6cm"/>
              <xsl:table-column column-width="5cm"/>
              
              <xsl:table-body>
                <xsl:apply-templates select="Employee"/>
              </xsl:table-body>
            </xsl:table>
          </xsl:block>
        </xsl:flow>
      </xsl:page-sequence>
    </xsl:root>
        </xsl:template>
        
         <!-- ========================= -->
  <!-- child element: Employee     -->
  <!-- ========================= -->
  <xsl:template match="Employee">
    <xsl:table-row>
      <xsl:if test="occupation = 'Tech Lead'">
        <xsl:attribute name="xslnt-weight">bold</xsl:attribute>
      </xsl:if>
      <xsl:if test="occupation = 'Manager'">
        <xsl:attribute name="xslnt-weight">bold</xsl:attribute>
        <xsl:attribute name="xslnt-color">Red</xsl:attribute>
      </xsl:if>

      <xsl:table-cell>
        <xsl:block>
          <xsl:value-of select="Name"/>
        </xsl:block>
      </xsl:table-cell>
      <xsl:table-cell>
        <xsl:block>
          <xsl:value-of select="Occupation"/>
        </xsl:block>
      </xsl:table-cell>
      <xsl:table-cell>
        <xsl:block>
          <xsl:value-of select="Email"/>
        </xsl:block>
      </xsl:table-cell>
    </xsl:table-row>
  </xsl:template>
</xsl:stylesheet>
————————

Camel Context

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
        xmlns:camel="http://camel.apache.org/schema/spring";
        xsi:schemaLocation="
         http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
         http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd";>

        <camelContext trace="true" 
xmlns="http://camel.apache.org/schema/spring";>

                <route>
                        <from uri="file:///tmp/dave/" />
                         <setProperty propertyName="lostHeader">
                        <simple>${header.lostHeader}</simple>
                </setProperty>
                        <to 
uri="xslt:file:///Users/pgajula/MyWorkspace/PDFGenCamelXML/src/main/resources/xslt/employeeReport.xsl"
 />
                        <to uri="fop:application/pdf" />
                        <to uri="file:///pdf/employeeReport.pdf" />
                </route>

        </camelContext>
</beans>

POM

<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
        <modelVersion>4.0.0</modelVersion>
        <groupId>PDFGenCamelFOPXML</groupId>
        <artifactId>PDFGenCamelXML</artifactId>
        <version>1.0</version>
        <name>PDFGenCamelXML</name>

        <properties>
                
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <camel.version>2.10.4</camel.version>
        </properties>

        <dependencies>
                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-core</artifactId>
                        <version>${camel.version}</version>
                </dependency>
                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-fop</artifactId>
                        <version>${camel.version}</version>
                </dependency>
<!--            <dependency>
                        <groupId>org.apache.xmlgraphics</groupId>
                        <artifactId>fop</artifactId>
                        <version>2.0</version>
                </dependency>
 -->            
                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-spring</artifactId>
                        <version>${camel.version}</version>
                </dependency>

                <!-- for testing -->
                <dependency>
                        <groupId>org.apache.camel</groupId>
                        <artifactId>camel-test</artifactId>
                        <version>${camel.version}</version>
                        <scope>test</scope>
                </dependency>
                
<!--            <dependency>
                        <groupId>org.apache.pdfbox</groupId>
                        <artifactId>pdfbox</artifactId>
                        <version>1.6.0</version>
                        <scope>test</scope>
                </dependency>
 -->
                <!-- logging -->
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                        <version>1.6.1</version>
                </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                        <version>1.6.1</version>
                        <scope>test</scope>
                </dependency>
                
                <dependency>
                        <groupId>log4j</groupId>
                        <artifactId>log4j</artifactId>
                        <version>1.2.16</version>
                        <scope>test</scope>
                </dependency>
        </dependencies>

        <build>

                <plugins>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-compiler-plugin</artifactId>
                                <version>2.5.1</version>
                                <configuration>
                                        <source>1.8</source>
                                        <target>1.8</target>
                                </configuration>
                        </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-jar-plugin</artifactId>
                                <configuration>
                                        <excludes>
                                                
<exclude>**/log4j.properties</exclude>
                                        </excludes>

                                </configuration>
                        </plugin>

                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-resources-plugin</artifactId>
                                <version>2.6</version>
                                <configuration>
                                        <encoding>UTF-8</encoding>
                                </configuration>
                        </plugin>

                        <plugin>
                                <groupId>org.apache.camel</groupId>
                                <artifactId>camel-maven-plugin</artifactId>
                                <version>${camel.version}</version>
                        </plugin>
                </plugins>
        </build>

</project>


When I run the code it hangs saying the below

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
Oct 21, 2015 1:22:51 PM 
org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing 
org.springframework.context.support.ClassPathXmlApplicationContext@621be5d1: 
startup date [Wed Oct 21 13:22:51 BST 2015]; root of context hierarchy
Oct 21, 2015 1:22:51 PM 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource 
[META-INF/spring/camel-context.xml]
Oct 21, 2015 1:22:51 PM 
org.springframework.beans.factory.support.DefaultListableBeanFactory 
preInstantiateSingletons
INFO: Pre-instantiating singletons in 
org.springframework.beans.factory.support.DefaultListableBeanFactory@56a6d5a6: 
defining beans [template,consumerTemplate,camel-1:beanPostProcessor,camel-1]; 
root of factory hierarchy
Currently, can only stop this by killing the JVM - needs fixing before going to 
production
Warning: Could not get charToByteConverterClass!


Could you provide any advise/guidance to fix this or provide a working sample 
code please.

Thanks
Praveen

Reply via email to