You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ulrich Mayring <ul...@denic.de> on 2000/03/10 12:42:28 UTC

Re: Transform an XML document to several formats

Mikael Ståldal wrote:
> 
> I have an XML document and two stylesheets to transform it to
> different formats (such as HTML and PDF). How do I set up Coccon to
> serv the document in the two different formats depending on the
> request URL?
> 
> Preferrably, I want document.xml to be transformed into HTML when the
> URL document.html is used, and to PDF when the URL document.pdf is
> used.

Quite easy, make document.xml an XML document that calls the
PDF-stylesheet and document.html an XML document that calls the HTML
stylesheet.

However, I'm not sure if this way of setting things up is good. What I
would do is have a central document.xml and make the distinction between
PDF and HTML in the stylesheet it calls. How to do that exactly depends
on your site organisation. For example, if you have an HTML page with a
button "This HTML page as PDF", then in the stylesheet for that HTML
page you can generate for this PDF button an URL like
"http://yourserver.domain.com/document.xml?type=pdf". In your stylesheet
you read that parameter and call the PDF-making stylesheet, whereas in
the absence of this parameter you serve an HTML page.

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung

Re: Transform an XML document to several formats

Posted by Russell Castagnaro <ru...@synctank.com>.
Shouldn't you be able to make a custom processor that checks to see what type of
client is accessing the page, then use the correct XSL file??


Mikael Ståldal wrote:

> On Fri, 10 Mar 2000, Ulrich Mayring wrote:
>
> > Quite easy, make document.xml an XML document that calls the
> > PDF-stylesheet and document.html an XML document that calls the HTML
> > stylesheet.
>
> You mean that I should maintain two copies of the same XML document.
> I don't like that solution.
>
> > However, I'm not sure if this way of setting things up is good.
>
> It's not.
>
> > What I
> > would do is have a central document.xml and make the distinction
> > between
> > PDF and HTML in the stylesheet it calls. How to do that exactly depends
> > on your site organisation. For example, if you have an HTML page with a
> > button "This HTML page as PDF", then in the stylesheet for that HTML
> > page you can generate for this PDF button an URL like
> > "http://yourserver.domain.com/document.xml?type=pdf". In your stylesheet
> > you read that parameter and call the PDF-making stylesheet, whereas in
> > the absence of this parameter you serve an HTML page.
>
> How do I read an URL parameter from a stylesheet? Can you show an
> example?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org

--

Russell Castagnaro
Chief Mentor
SyncTank Solutions
http://www.synctank.com

Earth is the cradle of mankind; one does not remain in the cradle forever
-Tsiolkovsky



Re: Transform an XML document to several formats

Posted by Stefano Mazzocchi <st...@apache.org>.
Ulrich Mayring wrote:
> 
> Mikael Ståldal wrote:
> 
> > How do I read an URL parameter from a stylesheet? Can you show an
> > example?
> 
> <xsp:expr>request.getParameter("myparam");</xsp:expr>

no, remove the ";" inside XSP expressions
 
-- 
Stefano Mazzocchi      One must still have chaos in oneself to be
                          able to give birth to a dancing star.
<st...@apache.org>                             Friedrich Nietzsche
--------------------------------------------------------------------
 Come to the first official Apache Software Foundation Conference!  
------------------------- http://ApacheCon.Com ---------------------



Re: Transform an XML document to several formats

Posted by Thorbjoern Ravn Andersen <ra...@mip.sdu.dk>.
On Sat, 11 Mar 2000, Thorbjoern Ravn Andersen wrote:

> Perhaps another approach could be to have identical copies of the
> source tree mounted at
> 
> 	/html
> 	/pdf
> 	/whatever
> 
> respectively.  Meaning that the /html/myfile.xml returns the html version,
> and /pdf/myfile.xml the pdf version. 

I forgot to say that this should be how the directory was presented to the
browser - there should only be one xml-file in the underlying filesystem.

-- 
  Thorbjørn Ravn Andersen               "...plus...Tubular Bells!"
  http://www.mip.sdu.dk/~ravn


Re: Transform an XML document to several formats

Posted by Thorbjoern Ravn Andersen <ra...@mip.sdu.dk>.
On Fri, 10 Mar 2000, Ulrich Mayring wrote:

> > How do I read an URL parameter from a stylesheet? Can you show an
> > example?
> 
> <xsp:expr>request.getParameter("myparam");</xsp:expr>

Perhaps another approach could be to have identical copies of the
source tree mounted at

	/html
	/pdf
	/whatever

respectively.  Meaning that the /html/myfile.xml returns the html version,
and /pdf/myfile.xml the pdf version. 

In order to do this transparently, it would be nice to ask for the URL to
this document, and split it into components.  Is that as easy as querying
for a parameter?

-- 
  Thorbjørn Ravn Andersen               "...plus...Tubular Bells!"
  http://www.mip.sdu.dk/~ravn


Re: Transform an XML document to several formats

Posted by Ulrich Mayring <ul...@denic.de>.
Mikael Ståldal wrote:

> How do I read an URL parameter from a stylesheet? Can you show an
> example?

<xsp:expr>request.getParameter("myparam");</xsp:expr>

Ulrich

-- 
Ulrich Mayring
DENIC eG, Softwareentwicklung

Re: Transform an XML document to several formats

Posted by Mikael Ståldal <d9...@d.kth.se>.
On Fri, 10 Mar 2000, Ulrich Mayring wrote:

> Quite easy, make document.xml an XML document that calls the
> PDF-stylesheet and document.html an XML document that calls the HTML
> stylesheet.

You mean that I should maintain two copies of the same XML document.
I don't like that solution.

> However, I'm not sure if this way of setting things up is good.

It's not.

> What I
> would do is have a central document.xml and make the distinction 
> between
> PDF and HTML in the stylesheet it calls. How to do that exactly depends
> on your site organisation. For example, if you have an HTML page with a
> button "This HTML page as PDF", then in the stylesheet for that HTML
> page you can generate for this PDF button an URL like
> "http://yourserver.domain.com/document.xml?type=pdf". In your stylesheet
> you read that parameter and call the PDF-making stylesheet, whereas in
> the absence of this parameter you serve an HTML page.

How do I read an URL parameter from a stylesheet? Can you show an
example?