Create page template that render valid XML to frontend

Topics: XSLT
May 23, 2012 at 7:14 PM

Hi guys,

I'd like to know if it's possible to create a pagetemplate that renders valid XML to the frontend. I'd like my XML output to come from a Function on my pages if possible.

I've tried playing around with it myself, but can't get it to work right.

So far this is the closest i've come to something useable:

 

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:rendering="http://www.composite.net/ns/rendering/1.0" xmlns:asp="http://www.composite.net/ns/asp.net/controls">
 <rendering:placeholder id="content" title="Content" default="true" />	
</root>

 

But this renderes something like this to my frontend:

 

<root xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:rendering="http://www.composite.net/ns/rendering/1.0" xmlns:asp="http://www.composite.net/ns/asp.net/controls">
	<html>
		<head></head>
		<body>
			Content from page
		</body>
	</html>
</root>

Can i somehow avoid the HTML elements and only get:

<root xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:rendering="http://www.composite.net/ns/rendering/1.0" xmlns:asp="http://www.composite.net/ns/asp.net/controls">
<myFunctionOutput>Content</myFunctionOutput>
</root>
// Martin

 

May 23, 2012 at 11:28 PM

If your goal is to call C1 Functions from the client, take a look at http://docs.composite.net/HTML/FrontendFAQ?q=Can+I+call+C1+Functions+AJAX+style+from+JavaScript+or+Flash%3F - you can call them directly, no need to do pages or templates :)