From: Christian S. <ch...@us...> - 2005-11-18 02:11:52
|
Update of /cvsroot/nmedit/website2/src/documentation/resources/stylesheets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11971/src/documentation/resources/stylesheets Added Files: dtdRef2document.xsl Log Message: new document type for writing DTD references --- NEW FILE: dtdRef2document.xsl --- <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="dtd"> <section> <title><xsl:value-of select="@title" /> - Reference</title> <xsl:if test="count(entity[@root='true'])>0"> <xsl:if test="(count(@show-top-level-elements)=0)or(@show-top-level-elements='true')"> <section> <title>Top-level element(s)</title> <ul> <xsl:for-each select="entity[@root='true']"> <li><a href="#elem.{@name}"><xsl:value-of select="@name" /></a></li> </xsl:for-each> </ul> </section> </xsl:if> </xsl:if> <xsl:if test="count(entity)>0"> <xsl:if test="(count(@show-element-list)=0)or(@show-element-list='true')"> <section> <title>List of elements</title> <ul> <xsl:for-each select="entity"> <xsl:sort select="@name"/> <li><a href="#elem.{@name}"><xsl:value-of select="@name" /></a></li> </xsl:for-each> </ul> </section> </xsl:if> <section> <title>Element declarations</title> <table class="DTDel"> <xsl:apply-templates select="entity"> <xsl:sort select="@name" /> </xsl:apply-templates> </table> </section> </xsl:if> </section> </xsl:template> <xsl:template match="entity"> <tr> <td class="DTDelTitle" colspan="2"> <xsl:value-of select="@name" /> <xsl:if test="@root='true'"> (top-level element)</xsl:if> <anchor id="elem.{@name}" /> </td> </tr> <xsl:if test="count(dtd-hint)!=0"> <tr><td class="DTDnote" colspan="2"><xsl:apply-templates select="dtd-hint" /></td></tr> </xsl:if> <tr> <td width="120"><b>Content model:</b></td> <td> <xsl:choose> <xsl:when test="count(contains)=0"> EMPTY </xsl:when> <xsl:otherwise> <xsl:apply-templates select="contains" /> </xsl:otherwise> </xsl:choose> </td> </tr> <tr> <td width="120x"><b>Attributes:</b></td> <td> <xsl:choose> <xsl:when test="count(attribute)=0"> <i>- none -</i> </xsl:when> <xsl:otherwise> <table class="DTDel"> <xsl:apply-templates select="attribute" /> </table> </xsl:otherwise> </xsl:choose> </td> </tr> <xsl:variable name="this" select="@name"/> <xsl:variable name="iused" select="../entity[contains/element/@entity-name=$this]"/> <tr> <td width="120"><b>Used inside</b></td> <td> <xsl:choose> <xsl:when test="count($iused)!=0"> <xsl:for-each select="$iused"> <xsl:sort select="@name" /> <link href="#elem.{@name}"><xsl:value-of select="@name" /></link> <xsl:if test="position()<count($iused)">, </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <i>- none -</i> </xsl:otherwise> </xsl:choose> </td> </tr> <tr> <td colspan="2" height="12"> </td> </tr> </xsl:template> <xsl:template match="contains"> <xsl:variable name="number" select="count(element)" /> <xsl:choose> <xsl:when test="$number!=0"> <xsl:for-each select="element"> <xsl:apply-templates select="." /> <xsl:if test="position()<$number">, </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="attribute"> <tr> <td class="DTDattName" width="120"><xsl:value-of select="@name" /></td> <td> <xsl:apply-templates select="attribute-type" /> </td> <td width="160"> <xsl:choose> <xsl:when test="@required='true'">required attribute</xsl:when> <xsl:when test="@implied='true'">implied attribute</xsl:when> <xsl:when test="string-length(@implicit-value)>0"> implied attribute <br/> implicit value: '<b><xsl:value-of select="@implicit-value"/></b>' </xsl:when> <xsl:when test="string-length(@default-value)>0"> default value: '<b><xsl:value-of select="@default-value"/></b>' </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> </td> </tr> <xsl:choose> <xsl:when test="count(dtd-hint)!=0"> <tr><td class="DTDhint" colspan="3"><xsl:apply-templates select="dtd-hint" /></td></tr> </xsl:when> <xsl:otherwise> <tr><td class="DTDhintE" colspan="3"> </td></tr> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="dtd-hint"> <xsl:apply-templates /> </xsl:template> <xsl:template match="attribute-type"> <xsl:variable name="number" select="count(option)" /> <xsl:choose> <xsl:when test="$number!=0"> Possible values: <xsl:for-each select="option"> <i><xsl:value-of select="@value" /></i> <xsl:if test="position()<$number">, </xsl:if> </xsl:for-each> </xsl:when> <xsl:otherwise> type: <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="element"> <xsl:variable name="reference" select="@entity-name" /> <xsl:choose> <xsl:when test="count(//dtd/entity[@name=$reference])>0"> <link href="#elem.{@entity-name}"><xsl:value-of select="@entity-name" /></link> </xsl:when> <xsl:otherwise> <xsl:value-of select="@entity-name" /> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="@* | node() | comment()"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> |