xsl.xmltohtml
来源:互联网 发布:阿里云搭建ss 贴吧 编辑:程序博客网 时间:2024/04/29 14:02
HTMLXSL.xslt.xml
生成效果如下
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="#"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="prefix" select="generate-id()"/>
<xsl:template match="/">
<style>
div.<xsl:value-of select="$prefix"/>global
{
font-family:arial;
}
span.<xsl:value-of select="$prefix"/>button
{
cursor:s-resize;
}
span.<xsl:value-of select="$prefix"/>nodemark
{
color:blue;
}
span.<xsl:value-of select="$prefix"/>nodename
{
color:brown;
}
div.<xsl:value-of select="$prefix"/>indent
{
margin-left:20;
}
span.<xsl:value-of select="$prefix"/>attributename
{
color:red;
}
span.<xsl:value-of select="$prefix"/>attributemark
{
color:blue;
}
span.<xsl:value-of select="$prefix"/>attributevalue
{
font-weight:bold;
}
</style>
<div>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>global</xsl:attribute>
<xsl:apply-templates select="." mode="node"/>
</div>
</xsl:template>
<xsl:template match="*" mode="node">
<xsl:choose>
<xsl:when test="count(*)=0"><xsl:apply-templates select="." mode="nodenochild"/></xsl:when>
<xsl:otherwise><xsl:apply-templates select="." mode="nodehavechild"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="nodenochild">
<div>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
</xsl:template>
<xsl:template match="*" mode="nodehavechild">
<xsl:variable name="id" select="generate-id()"/>
<div style="display='none'">
<xsl:attribute name="id"><xsl:value-of select="$id"/>shrink</xsl:attribute>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>button</xsl:attribute>
<xsl:attribute name="onclick"><xsl:value-of select="$id"/>expand.style.display='inline';<xsl:value-of select="$id"/>shrink.style.display='none';</xsl:attribute>
<xsl:text>+</xsl:text>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="id"><xsl:value-of select="$id"/>expand</xsl:attribute>
<div>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>button</xsl:attribute>
<xsl:attribute name="onclick"><xsl:value-of select="$id"/>expand.style.display='none';<xsl:value-of select="$id"/>shrink.style.display='inline';</xsl:attribute>
<xsl:text>-</xsl:text>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>indent</xsl:attribute>
<xsl:apply-templates select="*" mode="node"/>
</div>
<div>
<xsl:call-template name="lt"/>
<xsl:call-template name="slash"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:call-template name="gt"/>
</div>
</div>
</xsl:template>
<xsl:template match="*" mode="attributes">
<xsl:for-each select="@*">
<xsl:text> </xsl:text>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributename</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributemark</xsl:attribute>
<xsl:text>="</xsl:text>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributevalue</xsl:attribute>
<xsl:value-of select="."/>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributemark</xsl:attribute>
<xsl:text>"</xsl:text>
</span>
</xsl:for-each>
</xsl:template>
<xsl:template name="lt">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text><</xsl:text>
</span>
</xsl:template>
<xsl:template name="gt">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text>></xsl:text>
</span>
</xsl:template>
<xsl:template name="slash">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text>/</xsl:text>
</span>
</xsl:template>
<xsl:template match="*" mode="nodename">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodename</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
</xsl:template>
</xsl:transform>
<?xml-stylesheet type="text/xsl" href="#"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="prefix" select="generate-id()"/>
<xsl:template match="/">
<style>
div.<xsl:value-of select="$prefix"/>global
{
font-family:arial;
}
span.<xsl:value-of select="$prefix"/>button
{
cursor:s-resize;
}
span.<xsl:value-of select="$prefix"/>nodemark
{
color:blue;
}
span.<xsl:value-of select="$prefix"/>nodename
{
color:brown;
}
div.<xsl:value-of select="$prefix"/>indent
{
margin-left:20;
}
span.<xsl:value-of select="$prefix"/>attributename
{
color:red;
}
span.<xsl:value-of select="$prefix"/>attributemark
{
color:blue;
}
span.<xsl:value-of select="$prefix"/>attributevalue
{
font-weight:bold;
}
</style>
<div>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>global</xsl:attribute>
<xsl:apply-templates select="." mode="node"/>
</div>
</xsl:template>
<xsl:template match="*" mode="node">
<xsl:choose>
<xsl:when test="count(*)=0"><xsl:apply-templates select="." mode="nodenochild"/></xsl:when>
<xsl:otherwise><xsl:apply-templates select="." mode="nodehavechild"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="nodenochild">
<div>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
</xsl:template>
<xsl:template match="*" mode="nodehavechild">
<xsl:variable name="id" select="generate-id()"/>
<div style="display='none'">
<xsl:attribute name="id"><xsl:value-of select="$id"/>shrink</xsl:attribute>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>button</xsl:attribute>
<xsl:attribute name="onclick"><xsl:value-of select="$id"/>expand.style.display='inline';<xsl:value-of select="$id"/>shrink.style.display='none';</xsl:attribute>
<xsl:text>+</xsl:text>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="id"><xsl:value-of select="$id"/>expand</xsl:attribute>
<div>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>button</xsl:attribute>
<xsl:attribute name="onclick"><xsl:value-of select="$id"/>expand.style.display='none';<xsl:value-of select="$id"/>shrink.style.display='inline';</xsl:attribute>
<xsl:text>-</xsl:text>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>indent</xsl:attribute>
<xsl:apply-templates select="*" mode="node"/>
</div>
<div>
<xsl:call-template name="lt"/>
<xsl:call-template name="slash"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:call-template name="gt"/>
</div>
</div>
</xsl:template>
<xsl:template match="*" mode="attributes">
<xsl:for-each select="@*">
<xsl:text> </xsl:text>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributename</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributemark</xsl:attribute>
<xsl:text>="</xsl:text>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributevalue</xsl:attribute>
<xsl:value-of select="."/>
</span>
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>attributemark</xsl:attribute>
<xsl:text>"</xsl:text>
</span>
</xsl:for-each>
</xsl:template>
<xsl:template name="lt">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text><</xsl:text>
</span>
</xsl:template>
<xsl:template name="gt">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text>></xsl:text>
</span>
</xsl:template>
<xsl:template name="slash">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodemark</xsl:attribute>
<xsl:text>/</xsl:text>
</span>
</xsl:template>
<xsl:template match="*" mode="nodename">
<span>
<xsl:attribute name="class"><xsl:value-of select="$prefix"/>nodename</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
</xsl:template>
</xsl:transform>
<xsl:transform version="1.0">
<xsl:param name="prefix" select="generate-id()"/>
<xsl:template match="/">
<style>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
<xsl:value-of select="$prefix"/>
</style>
<div>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:apply-templates select="." mode="node"/>
</div>
</xsl:template>
<xsl:template match="*" mode="node">
<xsl:choose>
<xsl:when test="count(*)=0">
<xsl:apply-templates select="." mode="nodenochild"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="." mode="nodehavechild"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="*" mode="nodenochild">
<div>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
</xsl:template>
<xsl:template match="*" mode="nodehavechild">
<xsl:variable name="id" select="generate-id()"/>
<div style="display='none'">
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:value-of select="$id"/>
<xsl:value-of select="$id"/>
</xsl:attribute>
<xsl:text/>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="slash"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="id">
<xsl:value-of select="$id"/>
</xsl:attribute>
<div>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:value-of select="$id"/>
<xsl:value-of select="$id"/>
</xsl:attribute>
<xsl:text/>
</span>
<xsl:call-template name="lt"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:apply-templates select="." mode="attributes"/>
<xsl:call-template name="gt"/>
</div>
<div>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:apply-templates select="*" mode="node"/>
</div>
<div>
<xsl:call-template name="lt"/>
<xsl:call-template name="slash"/>
<xsl:apply-templates select="." mode="nodename"/>
<xsl:call-template name="gt"/>
</div>
</div>
</xsl:template>
<xsl:template match="*" mode="attributes">
<xsl:for-each select="@*">
<xsl:text/>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:text/>
</span>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:value-of select="."/>
</span>
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:text/>
</span>
</xsl:for-each>
</xsl:template>
<xsl:template name="lt">
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:text/>
</span>
</xsl:template>
<xsl:template name="gt">
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:text/>
</span>
</xsl:template>
<xsl:template name="slash">
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:text/>
</span>
</xsl:template>
<xsl:template match="*" mode="nodename">
<span>
<xsl:attribute name="class">
<xsl:value-of select="$prefix"/>
</xsl:attribute>
<xsl:value-of select="name()"/>
</span>
</xsl:template>
</xsl:transform>
- xsl.xmltohtml
- XSL
- xsl
- XSL
- XSL
- XSL
- XSL
- xsl
- XSL
- XSL
- xsl
- XSL
- XSL:XSL基础之一
- xsl:variable/xsl:param
- xsl:choose, xsl:when 和 xsl:otherwise
- 增强 XSL
- XSL函数
- XSL语法
- xsl.xmltobbs
- 基因模糊查询识别系统
- xml名称空间
- 大机学习之具体技术-文件系统及数据集概览
- Non-communicative multi-robot coordination in dynamic environments (二)
- xsl.xmltohtml
- 集合类的学习--集合类总揽
- vsftpd配置虚拟用户时遇到的一些小问题
- SVN提交数据失败问题
- 备份后的xp(有1.6G)怎样刻成光盘?
- 修改数据库的SID
- 备份精灵Ghost问答集锦
- 转自卓玛的博客-关于oracle的日常监控
- Ghost的一些异常情况