@pp.setOutputEncoding encoding="UTF-8" />
XML Tree Dump
<@dumpXml doc />
Legend:
- <foo bar="123">: Element node
- "Blah blah": Text node
- <?foo bar ?>: Processing instruction node
- <!-- Blah blah -->: Comment node
- foo: Other node
<#function showXmlSource s>
<#return s?xml?xml?replace(" ", r" ")?replace('\n', '
')?replace('\r', '
')>
#function>
<#--
Prints an XML node tree as colored HTML.
-->
<#macro dumpXml node>
<@dumpXml_internal node />
#macro>
<#macro dumpXml_internal node>
<#local type = node?node_type>
<#if type == 'element'>
<<#rt>
<#if node?node_namespace?? && node?node_namespace != ''>
'${node?node_namespace}':<#t>
#if>
${node?node_name}<#t>
<#list node.@@ as att>
${' '}<#t>
<#if att?node_namespace?? && att?node_namespace != ''>
'${att?node_namespace}':<#t>
#if>
${att?node_name}="${showXmlSource(att)}"<#t>
#list>
><#lt>
<#elseif type == 'text'>
"${showXmlSource(node)}"<#lt>
<#elseif type == 'pi'>
<#local nodeName = node?node_name>
<?${nodeName?substring(4)} ${showXmlSource(node)}?><#lt>
<#elseif type == 'comment'>
<!-- ${node} --><#lt>
<#else>
${node?node_type}<#lt>
#if>
<#if node?children?size != 0>
<#list node?children as c>
<@dumpXml_internal c /><#t>
#list>
#if>
#macro>