Hello everybody!
At runtime I receive xml document and I want to display it somehow different in JSF. For example:
This:
<invoker.ArrayOfDictionary>
<dictionary>
<invoker.Dictionary>
<id>gcide</id>
<name>The Collaborative International Dictionary of English v.0.48</name>
</invoker.Dictionary>
<invoker.Dictionary>
<id>wn</id>
<name>WordNet (r) 2.0</name>
</invoker.Dictionary>
<invoker.Dictionary>
<id>moby-thes</id>
<name>Moby Thesaurus II by Grady Ward, 1.0</name>
</invoker.Dictionary>
in this:
invoker.ArrayOfDictionary:
dictionary:
invoker.Dictionary:
id:gcide
name:The Collaborative International Dictionary of English v.0.48
invoker.Dictionary:
id:wn
name:WordNet (r) 2.0
invoker.Dictionary:
id:moby-thes
name:Moby Thesaurus II by Grady Ward, 1.0
I was thinking to do this with XSLT transformation. Some guidelines how to start with xslt? Or maybe you have another idea for this?
SOLVED:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="vNL" select="'
'"/>
<xsl:variable name="vSpaces" select="' '"/>
<xsl:template match="*">
<xsl:value-of select="concat(
$vNL,
substring($vSpaces,1,count(ancestor::node())),
$startBold,
name(),
':')"/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>
Thanks for the help!