cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Gries <grie...@java-concepts.com>
Subject Re: How can I get both a HTML and a PDF output from the same XML source file?
Date Sun, 11 Feb 2001 16:48:39 GMT
Hi,

if you can use a parameter to specify the output format, then following 
style should work (you have to refer to it in your xml file, of course).

At leats I use it in this way:

<?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:param name="out"/>
<xsl:param name="lang"/>

<xsl:template match="/">
  <xsl:processing-instruction 
name="cocoon-process">type="xslt"</xsl:processing-instruction>
   <xsl:choose>
   <xsl:when test="$out='html'">
         <xsl:processing-instruction 
name="xml-stylesheet">href="styles/style_html.xsl" 
type="text/xsl"</xsl:processing-instruction>
   </xsl:when>
   <xsl:when test="$out='pdf'">
         <xsl:processing-instruction 
name="xml-stylesheet">href="styles/style_fo.xsl" 
type="text/xsl"</xsl:processing-instruction>
   </xsl:when>
   <xsl:when test="$out='xml'">
         <xsl:processing-instruction 
name="xml-stylesheet">href="../styles/style_xml.xsl" 
type="text/xsl"</xsl:processing-instruction>
   </xsl:when>
   </xsl:choose>

<xsl:copy-of select="*root node of your xml source file*"/>

</xsl:template>
  
</xsl:stylesheet>

Hope this helps.
Olli


abottoni@quadrante.com wrote:

> I thoroughly read the FAQ (in particular the "How do I chain stylesheets" 
> item) and I tried hard to get both a (X)HTML and a PDF output from the
> same XML source file by applying two different XSL-T stylesheets.
> 
> The first stylesheet is a regular XML->(X)HTML converter and it works fine.
> 
> The second stylesheet tries to create a XSL-FO file from the XML source
> and post-process it with the Cocoon XSL:FO engine. This second XSL-T
> stylesheet does not work. I'm able to get a valid PDF file sent to my
> internet browser (MS IE 5.5 on Windows 98) but this PDF file is presented 
> in the browser window as it was a ASCII text file. Acrobat Reader is not
> invoked by the browser.
> 
> As long as I can understand, this happens because of the lacking of the
> <?xml version="1.0"?> element in the XSL:FO output produced by my XSL-T
> stylesheet. Unfortunatley, I cannot insert this element in my output
> using the "xsl:processing-instruction" because the XSL engine complains
> about an illegal operation ('processing-instruction cannot be "xml"'). I
> did not understand how to use the second technique mentioned in the "my
> processing instruction disapper..." of the FAQ, that is by using an
> "apply-templates" element that matches processing instructions, so I did
> not try it.
> 
> Does anybody know how to get both HTML and PDF output from the same XML
> file by applying two different stylesheets?
> 
> Does anybody have a working example of a single XML file converted into
> both HTML and PDF using different stylesheets?
> 
> Many thanks in advance
> 
> ---------------------
> Alessandro Bottoni
> Web Architect
> Quadrante SRL - Italy
> http://www.quadrante.com
> office: abottoni@quadrante.com
> personal: alessandro.bottoni@libero.it
> 
> 
> 
> ---------------------------------------------------------------------
> 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