----- Original Message -----
From: "Andreas Vallen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 13, 2002 5:55 PM
Subject: no way to get content-type?


> Hello cocoon-users,
>
> Is there really no way to determine the content type of a resource
> requested with a generator?
> I've spent some time since my last mail looking at the sources and it
seems
> as if cocoon in its current form can't handle this seemingly simple
task.
>
> Am I overlooking something?

Well, you just think the wrong way around ...

map:generate creates a stream of sax events. No MIME content type can
be applied to this. The content type of the URLSource is actually
determined by the Web-Server according to the extension of the file
it sends.

Looking at your sitemap example, might it be the case that you don't
want to determine the contenttype but the (XML) doctype of the
SAX stream ?

> Look at the following sitemap fragment for an example of what I want to
> achieve:
>
> <!-- get any resource, the exact content-type is unknown at
"compile-time" -->
> <map:generate src="**" type="file" />
>
>      <!-- select transformation according to content-type -->
>      <map:select type="contentType">
>
>             <map:when test="text/wml">
>               <map:transform src="wml2xhtml.xsl"/>
>               <map:serialize type="xhtml" />
>             </map:when>
>
>             <map:when test="text/chtml">
>               <map:transform src="chtml2xhtml.xsl"/>
>               <map:serialize type="xhtml" />
>             </map:when>
>
>             <map:otherwise>
>               <map:transform src="hdml2xhtml.xsl"/>
>               <map:serialize type="xhtml" />
>             </map:otherwise>
>
>        </map:select>

What's wrong with the following ?


<map:generate src="*.wml" type="file" />
  <map:transform src="wml2xhtml.xsl"/>
  <map:serialize type="xhtml" />
</map:generate>

<map:generate src="*.chtml" type="file" />
  <map:transform src="chtml2xhtml.xsl"/>
  <map:serialize type="xhtml" />
</map:generate>

<map:generate src="*.hdml" type="file" />
  <map:transform src="hdml2xhtml.xsl"/>
  <map:serialize type="xhtml" />
</map:generate>


... appropriate matchers ommited.

> I would hope that something along this way is easily implementable.
> To me it seems though as if I would have to dig deep into cocoon's
> classes ( URLSource.java came to my mind ) - something I'd like to
> avoid.
>
> thanks,
> Andreas Vallen
>

Regards,


Jens

--

jens.lorenz at interface-projects dot de

interface:projects GmbH                             \\|//
Tolkewitzer Strasse 49                              (o o)
01277 Dresden                               ~~~~oOOo~(_)~oOOo~~~~
Germany


---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to