cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yvon Bricole <yvon.bric...@free.fr>
Subject Re: Cocoon 2.0 sitemap
Date Fri, 22 Feb 2002 06:21:30 GMT
>What's the secret to getting Cocoon 2.0 to serve up PDF files? Is it the
>sitemap file? Do I have to edit it? 
>I have one xml file and one xsl-fo file. How does Cocoon put the two
together?
>
>G.Howze

no secret at all !

read the samples, as for example one of cocoon folder just modified a
little bit :

---------------

XML file : salutMonde.xml (Hello World in french ;-)) )

---------------
<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="hello-fo.xsl" type="text/xsl"?>
<page>
 <title>Salut Monde !</title>
 <content>
  <paragraph>mon premier essai xml -- pdf avec Cocoon!</paragraph>
 </content>
</page>
---------------

XSL file : hello-fo.xsl

---------------
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">

  <xsl:template match="page">
    <xsl:processing-instruction name="cocoon-format">type="text/xslfo"</
xsl:processing-instruction>
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master
      page-master-name="one"
      margin-left="100pt"
      margin-right="100pt">
   <fo:region-body margin-top="50pt"
       margin-bottom="50pt"/>
  </fo:simple-page-master>
 </fo:layout-master-set>

 <fo:page-sequence>
  <fo:sequence-specification>
   <fo:sequence-specifier-repeating
       page-master-first="one"
       page-master-repeating="one"/>
  </fo:sequence-specification>

  <fo:flow font-size="14pt" line-height="14pt">
   <fo:block><xsl:value-of select="title"/></fo:block>  
   <fo:block space-before.optimum="12pt" text-align="centered">
     <xsl:value-of select="content/paragraph"/>
   </fo:block>
   </fo:flow>
 </fo:page-sequence> 
</fo:root>
  </xsl:template>

  <xsl:template match="title/content">
    <fo:block font-size="36pt" text-align-last="centered" space-
before.optimum="24pt"><xsl:apply-templates/></fo:block>
  </xsl:template>

</xsl:stylesheet>
---------------
put those two files onto your cocoon folder
start up cocoon

point a web browser to the adress : 

<http://127.0.0.1:8080/cocoon-1.8/salutMonde.xml>

cocoon-1.8 being the folder name of cocoon, this suppose salutMonde.xml
is at root of this folder.
Notice cocoon knows it as to link the xml to the other xsl because it's
written on top of the xml one...

that's all folks !

Yvon


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message