From: Jan T. <de...@us...> - 2003-06-03 22:39:00
|
Update of /cvsroot/net-script/netscript2/src/scripts In directory sc8-pr-cvs1:/tmp/cvs-serv22656 Added Files: src.xml src.xsl Log Message: * added script for displaying source code --- NEW FILE: src.xml --- <?xml version="1.0"?> <!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # NetScript 2.0 Demo Script - Displays the source code of another # script. # $Id: src.xml,v 1.1 2003/06/03 22:38:57 derkork Exp $ # # NetScript and all related materials, such as documentation, # are protected under the terms and conditions of the Artistic License. # (C) 2000-2002 by Jan Thomae, insOMnia # mailto: ko...@in... +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--> <!-- Source code of the script --> <?netscript use XSLT?> <ns:ignore xmlns:ns="http://netscript.insomnia-hq.de"> <?netscript include $(P.src)?> <xsl:transform default="./src.xsl" xmlns:xsl="http://xslt.netscript.insomnia-hq.de"/> </ns:ignore> <!-- End source code --> --- NEW FILE: src.xsl --- <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://netscript.insomnia-hq.de" version="1.0"> <xsl:preserve-space elements="*"/> <xsl:variable name="bgColor">#F7F7D7</xsl:variable> <xsl:variable name="commentColor">#AE6579</xsl:variable> <xsl:variable name="pcColor">#9696EF</xsl:variable> <xsl:variable name="tagColor">#9696EF</xsl:variable> <xsl:variable name="attributeNameColor">#9E9Af7</xsl:variable> <xsl:variable name="attributeValueColor">#DFA620</xsl:variable> <!-- match the root node --> <xsl:template match="/"> <html> <head> <!-- Set UTF-8 for   --> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Source code</title> </head> <body bgcolor="{$bgColor}"> <pre> <xsl:apply-templates/> </pre> </body> </html> </xsl:template> <!-- match all tags --> <xsl:template match="*"> <font color="{$tagColor}"><b><<xsl:value-of select="name()"/></b></font> <xsl:apply-templates select="@*"/> <xsl:choose> <!-- no child nodes --> <xsl:when test="count(./node()) = 0"><font color="{$tagColor}"><b>/></b></font> </xsl:when> <!-- apply child nodes --> <xsl:otherwise> <font color="{$tagColor}"><b>></b></font> <xsl:apply-templates/> <font color="{$tagColor}"><b></<xsl:value-of select="name()"/>></b></font> </xsl:otherwise> </xsl:choose> </xsl:template> <!-- match comment --> <xsl:template match="comment()"> <font color="{$commentColor}"><i><!--<xsl:value-of select="."/>--></i><br/></font> </xsl:template> <!-- match processing instruction --> <xsl:template match="processing-instruction()"> <font color="{$pcColor}"><b><?<xsl:value-of select="name()"/></b> <i><xsl:value-of select="."/></i> <b>?></b></font> </xsl:template> <!-- match all attributes --> <xsl:template match="@*"> <font color="{$attributeNameColor}"> <xsl:value-of select="name()"/>=</font><font color="{$attributeValueColor}">"<xsl:value-of select="."/>"</font></xsl:template> <!-- match text --> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> |