* added support for <property name="xyz"> elements

* prefer output of prototyperef value rather than generic "HopObject" whenever possible
* fixed linebreaks (somehow they appeared corrupted on my machine)
This commit is contained in:
Tobi Schäfer 2004-07-06 14:28:18 +00:00
parent dc5bba8ddd
commit d45f7a1e99

View file

@ -1,127 +1,155 @@
<?xml version="1.0" encoding="iso-8859-15"?> <?xml version="1.0" encoding="iso-8859-15"?>
<xsl:stylesheet <xsl:stylesheet
version="1.0" version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:hop="http://www.helma.org/docs/guide/features/database" xmlns:hop="http://www.helma.org/docs/guide/features/database"
> >
<xsl:output method="html"/> <xsl:output method="html"/>
<xsl:template match="/"> <xsl:template match="/">
<html> <xsl:variable name="id" select="/xmlroot/hopobject/@id"/>
<head>
<title>Helma Object Publisher XML Database File</title> <html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" /> <head>
</head> <title><xsl:value-of select="$id"/>.xml (Hop XML Database File)</title>
<body bgcolor="white"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
</head>
<xsl:variable name="id" select="/xmlroot/hopobject/@id"/> <body bgcolor="white">
<h2>
<xsl:if test="$id = 0">root</xsl:if> <h2>
<xsl:if test="$id &gt; 0"> <xsl:if test="$id = 0">root</xsl:if>
<a href="0.xml">root</a> : HopObject <xsl:value-of select="$id"/> <xsl:if test="$id &gt; 0">
</xsl:if> <a href="0.xml">root</a> : HopObject <xsl:value-of select="$id"/>
</h2> </xsl:if>
</h2>
<table border="0" cellspacing="1" cellpadding="5" bgcolor="gray">
<tr bgcolor="white"> <table border="0" cellspacing="1" cellpadding="5" bgcolor="gray">
<th>Name</th> <tr bgcolor="white">
<th>Value</th> <th>Name</th>
</tr> <th>Value</th>
</tr>
<xsl:variable name="name" select="/xmlroot/hopobject/@name"/>
<xsl:if test="$name"> <xsl:variable name="name" select="/xmlroot/hopobject/@name"/>
<xsl:call-template name="property"> <xsl:if test="$name">
<xsl:with-param name="name">_name</xsl:with-param> <xsl:call-template name="property">
<xsl:with-param name="value" select="$name"/> <xsl:with-param name="name">_name</xsl:with-param>
</xsl:call-template> <xsl:with-param name="value" select="$name"/>
</xsl:if> </xsl:call-template>
</xsl:if>
<xsl:variable name="prototype" select="/xmlroot/hopobject/@prototype"/>
<xsl:if test="$prototype"> <xsl:variable name="prototype" select="/xmlroot/hopobject/@prototype"/>
<xsl:call-template name="property"> <xsl:if test="$prototype">
<xsl:with-param name="name">_prototype</xsl:with-param> <xsl:call-template name="property">
<xsl:with-param name="value" select="$prototype"/> <xsl:with-param name="name">_prototype</xsl:with-param>
</xsl:call-template> <xsl:with-param name="value" select="$prototype"/>
</xsl:if> </xsl:call-template>
</xsl:if>
<xsl:variable name="parent" select="/xmlroot/hopobject/hop:parent"/>
<xsl:if test="$parent"> <xsl:variable name="parent" select="/xmlroot/hopobject/hop:parent"/>
<xsl:call-template name="property"> <xsl:if test="$parent">
<xsl:with-param name="name">_parent</xsl:with-param> <xsl:call-template name="property">
<xsl:with-param name="value"> <xsl:with-param name="name">_parent</xsl:with-param>
HopObject <xsl:value-of select="$parent/@idref"/> <xsl:with-param name="value">
</xsl:with-param> HopObject <xsl:value-of select="$parent/@idref"/>
<xsl:with-param name="href"> </xsl:with-param>
<xsl:value-of select="$parent/@idref"/>.xml <xsl:with-param name="href">
</xsl:with-param> <xsl:value-of select="$parent/@idref"/>.xml
</xsl:call-template> </xsl:with-param>
</xsl:if> </xsl:call-template>
</xsl:if>
<xsl:variable name="children" select="/xmlroot/hopobject/hop:child"/>
<xsl:if test="count($children) &gt; 0"> <xsl:variable name="children" select="/xmlroot/hopobject/hop:child"/>
<tr bgcolor="white"> <xsl:if test="count($children) &gt; 0">
<td valign="top" nowrap="nowrap">_children</td> <tr bgcolor="white">
<td> <td valign="top" nowrap="nowrap">_children</td>
<xsl:for-each select="/xmlroot/hopobject/hop:child"> <td>
<xsl:sort select="@idref" data-type="number"/> <xsl:for-each select="/xmlroot/hopobject/hop:child">
<a href="{@idref}.xml">HopObject <xsl:value-of select="@idref"/></a> <xsl:sort select="@idref" data-type="number"/>
<xsl:if test="position() &lt; count($children)"> <a href="{@idref}.xml"><nowrap><xsl:value-of select="@prototyperef"/>
<xsl:text>, </xsl:text> <xsl:text> </xsl:text><xsl:value-of select="@idref"/></nowrap></a>
</xsl:if> <xsl:if test="position() &lt; count($children)">
</xsl:for-each> <xsl:text>, </xsl:text>
</td> </xsl:if>
</tr> </xsl:for-each>
</xsl:if> </td>
</tr>
<xsl:for-each select="/xmlroot/hopobject/*"> </xsl:if>
<xsl:sort select="name()"/>
<xsl:choose> <xsl:for-each select="/xmlroot/hopobject/*">
<xsl:when test="name() = 'hop:parent'"/> <xsl:sort select="@name"/>
<xsl:when test="name() = 'hop:child'"/> <xsl:sort select="name()"/>
<xsl:when test="@idref"> <xsl:choose>
<xsl:call-template name="property"> <xsl:when test="name() = 'hop:parent'"/>
<xsl:with-param name="name"> <xsl:when test="name() = 'hop:child'"/>
<xsl:value-of select="name()"/> <xsl:when test="@idref">
</xsl:with-param> <xsl:call-template name="property">
<xsl:with-param name="value"> <xsl:with-param name="name">
HopObject <xsl:value-of select="@idref"/> <xsl:value-of select="name()"/>
</xsl:with-param> </xsl:with-param>
<xsl:with-param name="href"> <xsl:with-param name="value">
<xsl:value-of select="@idref"/>.xml HopObject <xsl:value-of select="@idref"/>
</xsl:with-param> </xsl:with-param>
</xsl:call-template> <xsl:with-param name="href">
</xsl:when> <xsl:value-of select="@idref"/>.xml
<xsl:otherwise> </xsl:with-param>
<xsl:call-template name="property"> </xsl:call-template>
<xsl:with-param name="name"><xsl:value-of select="name()"/></xsl:with-param> </xsl:when>
<xsl:with-param name="value"><xsl:value-of select="text()"/></xsl:with-param> <xsl:otherwise>
</xsl:call-template> <xsl:call-template name="property">
</xsl:otherwise> <xsl:with-param name="name">
</xsl:choose> <xsl:if test="name() = 'property'">
</xsl:for-each> <xsl:value-of select="@name"/>
</xsl:if>
</table> <xsl:if test="name() != 'property'">
</body> <xsl:value-of select="name()"/>
</html> </xsl:if>
</xsl:template> </xsl:with-param>
<xsl:with-param name="value"><xsl:value-of select="text()"/></xsl:with-param>
<xsl:template name="property"> </xsl:call-template>
<xsl:param name="name"/> </xsl:otherwise>
<xsl:param name="type"/> </xsl:choose>
<xsl:param name="href"/> </xsl:for-each>
<xsl:param name="value"/>
</table>
<tr bgcolor="white"> </body>
<td valign="top" nowrap="nowrap"><xsl:value-of select="$name"/></td> </html>
<td><xsl:if test="$href"> </xsl:template>
<a href="{$href}"><xsl:value-of select="$value"/></a>
</xsl:if> <xsl:template name="property">
<xsl:if test="$href = ''"> <xsl:param name="name"/>
<xsl:value-of select="$value"/> <xsl:param name="type"/>
</xsl:if></td> <xsl:param name="href"/>
</tr> <xsl:param name="value"/>
</xsl:template> <xsl:param name="display">
<xsl:call-template name="getName">
</xsl:stylesheet> <xsl:with-param name="name" select="$value"/>
</xsl:call-template>
</xsl:param>
<tr bgcolor="white">
<td valign="top" nowrap="nowrap"><xsl:value-of select="$name"/></td>
<td><xsl:if test="$href">
<a href="{$href}"><xsl:value-of select="$display"/></a>
</xsl:if>
<xsl:if test="$href = ''">
<xsl:value-of select="$display"/>
</xsl:if>
</td>
</tr>
</xsl:template>
<xsl:template name="getName">
<xsl:param name="name"/>
<xsl:param name="isRoot" select="substring-after($name, 'HopObject ') = '0'"/>
<xsl:if test="$isRoot">
root
</xsl:if>
<xsl:if test="$isRoot = false">
<xsl:value-of select="$name"/>
</xsl:if>
</xsl:template>
</xsl:stylesheet>