cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Patrick Refondini <patrick.refond...@pobox.com>
Subject Re: content-type=text/xml output, how to configure
Date Thu, 09 Nov 2006 23:41:08 GMT
Hi Hank,

Hank Ratzesberger wrote:
> 
> I am using the eXist database which is built on Cocoon.  It has a REST 
> interface that accepts
> XPath and XQuery request parameters.
> 
> My problem is that the returned content-type is
> text/html, but I want to force it to be text/xml.
> 
> Is there a bare minimum sitemap.xmap file that I can start with? 
> It seems like I change the piplelines and default serializer, etc., etc.,
> but I get the same results.

Maybe this simple example might help:

In a test sitemap.xmap add:

   <map:match pattern="HTML_*">
     <map:generate src="{1}.xml" />
     <map:serialize type="html"/>
   </map:match>

   <map:match pattern="XML_*">
     <map:generate src="{1}.xml" />
     <map:serialize type="xml"/>
   </map:match>

Then define a file test1.xml containing:

<?xml version="1.0" encoding="utf-8"?>
<div xmlns="http://www.w3.org/1999/xhtml">
	<table border="1" width="50%">
		<tbody>
			<tr>
				<td>HTML namespace</td>
				<td>http://www.w3.org/1999/xhtml</td>
			</tr>
		</tbody>
	</table>
</div>

Then define a file test2.xml containing:

<?xml version="1.0" encoding="utf-8"?>
<div>
	<table border="1" width="50%">
		<tbody>
			<tr>
				<td>Default namespace</td>
				<td>nada</td>
			</tr>
		</tbody>
	</table>
</div>

Finally given a URL context ${YOUR_URL} with your browser hit:

${YOUR_URL}/XML_test1
${YOUR_URL}/HTML_test1
${YOUR_URL}/XML_test2
${YOUR_URL}/HTML_test2

Looking at your browser page source will show you four different 
results, the first one being likely the result you want.

For more information on e.g. controlling encoding you may want to read:

http://cocoon.apache.org/2.1/userdocs/xml-serializer.html

I hope this helps,

Patrick

> 
> Regards from a first time visitor,
> 
> Hank Ratzesberger
> Goleta, CA
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 


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


Mime
View raw message