Hi,
I have a source XML file with following general structure:
<root>
<element>text</element> occurence 0 to unbounded
<element href="URL"/> occurence 0 to unbounded
<element>***</element> *** means a structure like root;
occurence 0 to unbounded
</root>
I'm trying to develope a generic html visualization for such a XML
document. As you can see by the *** recursion is involved. But I don't
know how to handle it exactly? I think I need another key which groups
the *** root elements? Does anyone have a solution? At the Moment my XSL
looks like that:
Key defined in other XSL:
<xsl:key name="elementtags-by-name" match="*" use="name(.)"/>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:iese.config="http://www.iese.fhg.de/config"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="iese.config">
<xsl:output method="xml" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>
<xsl:template name="default-ul">
<xsl:variable name="unique-elements"
select="*[generate-id()=generate-id(key('elementtags-by-name',name()))]"
/>
<ul>
<xsl:for-each select="$unique-elements">
<xsl:variable name="elements-by-name"
select="key('elementtags-by-name', name())"/>
<xsl:choose>
<xsl:when test="@href">
<xsl:apply-templates
select="$elements-by-name" mode="association_aggregation_ul"/>
</xsl:when>
<xsl:when test="child::*">
<li>
<xsl:value-of
select="name()"/>
</li>
<ul>
<xsl:apply-templates select="current()/*" mode="composition_ul"/>
</ul>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates
select="$elements-by-name" mode="attribute_ul"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</ul>
</xsl:template>
<xsl:template match="*" mode="attribute_ul">
<li>
<xsl:value-of select="current()"/>
</li>
</xsl:template>
<xsl:template match="*" mode="association_aggregation_ul">
<li>
<a href="{(_at_)href}">
<xsl:value-of
select="document(@href)/*/*[1]"/>
</a>
</li>
</xsl:template>
<xsl:template match="*" mode="composition_ul">
<li>
<xsl:value-of select="current()/*"/>
</li>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list