Generic template question

Kirill <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Hello,

I am trying to create a generic freemarker template, used to be able  
to work with any model.

For example, it would be able to take an XML, as a model, like this:
<root>
<child1>content</child1>
</root>
and this as well:
<root>
<child1>
	<child2>content</child2>
</child1>
</root>

Now, I can get all nodes and text content (tags and content in those  
tags), like this:

<#ftl>

<#recurse doc>

<#macro @element>
	${.node.@@start_tag}
	<#if .node?children?size = 1>
		${r"${"}${.node.@@qname}${r"}"}
	</#if>
	<#if .node?children?size &gt; 0>
		<#recurse>
	</#if>
	${.node.@@end_tag}
</#macro>

<#macro @text>
</#macro>

This will effectively recurse through all tags and clean up the @text  
content.

The question is - how do I get to the bound namespaces and attributes?
For example, if I get a tag like: <root attribute="value"/>, how do I  
get to "attribute" and its' "value"?
Or, if I get a tag like <root xmlns:namespace="HTTP://foo"/>, how do I  
retrieve the "xmlns:namespace" part (and its' value)?

Thanks for all the input.

- Kirill

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.