您的位置:首页 > 其它

PKM2数据导出的xml显示用的XSL

2010-01-11 03:05 288 查看
PKM2这个个人知识管理软件相信很多人用过,可以把数据导出为chm电子书,但是不知道为什么倒出来的chm不能按照标题排序,所以我就导出为xml格式,弄个xsl来显示它.



<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"  version="4.0" indent="yes"/>
	
<xsl:template match="/">
<html>
<head>
<TITLE>hh</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<meta name="Author" content="(webuc.net)" />
<meta name="Description" content="" />
<mce:style><!--
body{margin:0px;color:black;font-size:9pt;}
div{background-color:#fff;border:1px solid #4682B4;}
p{indent:2em;margin-left:15px;}
ul{}

li{margin-left:10px;}
a:link    {color: #2c4c78; text-decoration: none}
a:visited {color: #2c4c78; text-decoration: none}
a:hover   {color: #8B0C01; text-decoration: underline}
a:active  {color: red; text-decoration: none}
#left_nav{margin:10px;float:left;clear:left;width:250px;height:600px;overflow:scroll;}
#right_content{margin:10px;float:left;clear:right;width:600px;height:600px;overflow:scroll;}
--></mce:style><style mce_bogus="1">body{margin:0px;color:black;font-size:9pt;}
div{background-color:#fff;border:1px solid #4682B4;}
p{indent:2em;margin-left:15px;}
ul{}

li{margin-left:10px;}
a:link    {color: #2c4c78; text-decoration: none}
a:visited {color: #2c4c78; text-decoration: none}
a:hover   {color: #8B0C01; text-decoration: underline}
a:active  {color: red; text-decoration: none}
#left_nav{margin:10px;float:left;clear:left;width:250px;height:600px;overflow:scroll;}
#right_content{margin:10px;float:left;clear:right;width:600px;height:600px;overflow:scroll;}</style>
</head>

<body>
<div id="main">

  <xsl:apply-templates select="XMLDB"/>

</div>
</body>
</html>
</xsl:template>

<xsl:template match="XMLDB">
<div id="left_nav"><xsl:apply-templates select="NodeList"/></div>
<div id="right_content"><xsl:apply-templates select="ItemList"/></div>
</xsl:template>

<xsl:template match="NodeList">

    <h1><xsl:value-of select="Node/Category" /></h1>

<ul>
<xsl:for-each select="//XMLDB//ItemList//Item"> 

    <xsl:sort select="Title" order="ascending"/>
    <li>
        <xsl:element name="a">
        	<xsl:attribute name="href">#<xsl:value-of select="IDKey" /></xsl:attribute>
        	<xsl:value-of select="Title" />
        </xsl:element>
    </li>

</xsl:for-each> 

</ul>
</xsl:template>

<xsl:template match="ItemList">

    <xsl:for-each select="Item"> 
    
        <p>
        <xsl:element name="a">
        	<xsl:attribute name="name">#<xsl:value-of select="IDKey" /></xsl:attribute>
        </xsl:element>   
        
    	<xsl:value-of select="Content" disable-output-escaping="yes" />
    	</p>
    
    
    </xsl:for-each> 

</xsl:template>

</xsl:stylesheet>




XSL代码如上,xsl文件保存为: show.xsl,修改XMLDB.xml文件,

<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="show.xsl"?>+++++插入左边的这一行.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: