Sorry peopole but I am not following this, I apologise if I am coming across retarded.  Would someone be kind enough as to show me how to convert my existing hello world files to achieve:


A)place both xml and xsl in one file(how would the new file look)
B)how to change the fop program to accept this as input and produce output


Existing xml file:
<?xml version="1.0" encoding="UTF-8"?>
<data>
        <param1>hello</param1>
        <param2>world</param2>
</data>

Existing xsl file:

<?xml version="1.0" encoding="UTF-8"?>
<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="/">

 <fo:root xmlns:fo="
http://www.w3.org/1999/XSL/Format">

   <fo:layout-master-set>
     <fo:simple-page-master master-name="simple"
                   page-height="29.7cm"
                   page-width="21cm"
                   margin-top="0.2cm"
                   margin-bottom="2cm"
                   margin-left="2.5cm"
                   margin-right="2.5cm">
       <fo:region-body margin-top="2cm"/>
       <fo:region-before extent="3cm"/>
       <fo:region-after extent="1.5cm"/>
     </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="data"/>
        </fo:flow>
   </fo:page-sequence>
  </fo:root>
 </xsl:template>

 <xsl:template match="data">
       <fo:block>
        <xsl:apply-templates select="param1"/>
        <xsl:apply-templates select="param2"/>
       </fo:block>      
 </xsl:template>

<xsl:template match="param1">
       <fo:block font-size="12pt"
                 font-family="sans-serif"
                 space-after.optimum="30pt"
                 text-align="justify">
                <xsl:value-of select="."/>
        </fo:block>
</xsl:template>


<xsl:template match="param2">
       <fo:block font-size="12pt"
                 space-before.optimum="110pt"
                 text-align="justify">
                <xsl:value-of select="."/>
        </fo:block>
</xsl:template>
</xsl:stylesheet>

Existing fop program:

 FopFactory fopFactory = FopFactory.newInstance();
                            String doc = "helloworld" ;
                                OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(doc+".pdf")));
                               
                                try {
               
                                  Fop fop = fopFactory.newFop("application/pdf",  out);
                                  TransformerFactory factory = TransformerFactory.newInstance();
                                  Source xslt = new StreamSource(new File(doc+".xsl"));
                                  Transformer transformer = factory.newTransformer(xslt);
                                  Source src = "" StreamSource(new File(doc+".xml"));
                                  Result res = new SAXResult(fop.getDefaultHandler());
                                  transformer.transform(src, res);
                                 
                                } finally {....




many thanks

-----Original Message-----
From: Florent Georges [mailto:[EMAIL PROTECTED]]
Sent: 22 May 2006 13:44
To: fop-users@xmlgraphics.apache.org
Subject: RE: Seperating xml and tempalte but using one file

Shamem Miah wrote:

> Sorry I didn't understand that.  Is it possible you can provide a link
> with an example or explanation?

  You can view the XSLT FAQ about the identity transformation:

    http://www.dpawson.co.uk/xsl/sect2/identity.html

  Basically, try something like that for the first transformation:

    <xsl:transform
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fo="http://www.w3.org/1999/XSL/Format"
        xmlns:x_="http://www.fgeorges.org/Transform/Alias"
        version="2.0">

      <xsl:namespace-alias stylesheet-prefix="x_"
                           result-prefix="xsl"/>

      <xsl:template match="@*|node()">
        <xsl:copy>
          <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
      </xsl:template>

      <xsl:template match="fo:*/text()">
        <!-- Try to set a variable, instead. -->
        <x_:value-of select="doc('')/to-datas/{.}"/>
      </xsl:template>

    </xsl:transform>

  It will transform the fo:* elements by wrapping their text nodes into xsl:value-of elements.  So you'll give an XSLT script.  Then use this script as usual, to produce the FO.

  You'll have maybe to customize the template rule matching "/", depending on what your document looks like (is it an FO or XSLT document?, etcetera).

  Regards,

--drkm

























       

       
               
___________________________________________________________________________
Faites de Yahoo! votre page d'accueil sur le web pour retrouver directement vos services préférés : vérifiez vos nouveaux mails, lancez vos recherches et suivez l'actualité en temps réel.
Rendez-vous sur http://fr.yahoo.com/set

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to