如何为sitemap.xml写对应的xsl文件

wxlcanary 2009-08-17 02:09:50
我的sitemap.xml如下:
<node><title>Home</title><link><a href="/CMS400Developer/default.aspx" alt="Medical Home">Home</a></link><description>Medical Home</description><node><title>About Us</title><link><a href="/CMS400Developer/aboutus.aspx" alt="About Medical">About Us</a></link><description>About Medical</description><node><title>Staff</title><link><a href="/CMS400Developer/staff.aspx" alt="Staff list">Staff</a></link><description>Staff list</description></node><node><title>News</title><link><a href="/CMS400Developer/news.aspx" alt="News">News</a></link><description>News</description></node><node><title>Careers</title><link><a href="/CMS400Developer/jobs.aspx" alt="Careers at Medical Center">Careers</a></link><description>Careers at Medical Center</description></node><node><title>Calender</title><link><a href="/CMS400Developer/events.aspx" alt="">Calender</a></link><description></description></node></node><node><title>Services</title><link><a href="/CMS400Developer/services.aspx" alt="Services">Services</a></link><description>Services</description></node><node><title>Products</title><link><a href="/CMS400Developer/products.aspx" alt="Product page">Products</a></link><description>Product page</description></node><node><title>Therapies</title><link><a href="/CMS400Developer/therapies.aspx" alt="Therapies">Therapies</a></link><description>Therapies</description></node><node><title>Conditions</title><link><a href="/CMS400Developer/conditions.aspx" alt="Conditions">Conditions</a></link><description>Conditions</description><node><title>Wellness Articles</title><link><a href="/CMS400Developer/wellness_article.aspx" alt="Wellness Articles">Wellness Articles</a></link><description>Wellness Articles</description></node></node><node><title>Contact Information</title><link><a href="/CMS400Developer/contactinformation.aspx" alt="Contact Information">Contact Information</a></link><description>Contact Information</description></node><node><title>Blog</title><link><a href="/CMS400Developer/blogs.aspx" alt="Blog">Blog</a></link><description>Blog</description></node><node><title>Search</title><link><a href="/CMS400Developer/search.aspx" alt="Search">Search</a></link><description>Search</description></node></node>

希望输出的结果是:
Home
About Us
Staff
News
Careers
Calender
Services
Products
Therapies
Conditions
Wellness Articles
Contact Information
Blog
Search

我不太会写xsl,有谁能帮助提供一个简单的xsl模版,只要实现这种阶梯结构就行。多谢了!
...全文
122 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
duqinfang 2011-05-20
  • 打赏
  • 举报
回复
牛气,我最佩服牛气的人了,好像什么都会。
hookee 2009-08-17
  • 打赏
  • 举报
回复

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/node">
<ul>
<li>
<a><xsl:attribute name="href"><xsl:value-of select="link/a/@href"/></xsl:attribute><xsl:value-of select="title"/></a>
</li>
<xsl:apply-templates select="node"></xsl:apply-templates>
</ul>
</xsl:template>
<xsl:template match="node">
<li>
<a><xsl:attribute name="href"><xsl:value-of select="link/a/@href"/></xsl:attribute><xsl:value-of select="title"/></a>
</li>
<xsl:for-each select="./node">
<ul>
<xsl:apply-templates select="."></xsl:apply-templates>
</ul>
</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

wxlcanary 2009-08-17
  • 打赏
  • 举报
回复
太好了,完全解决了问题。 多谢!
wxlcanary 2009-08-17
  • 打赏
  • 举报
回复
我尝试写了一个xsl. 可以在http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=cdcatalog_ex2 网中调试。 目前的问题有两个:
1.如何打印出二级目录
2.如何给输出的目录加上链接. 例如:<a href="/CMS400Developer/blogs.aspx" alt="Blog">Blog </a>。这样用户可以点击链接进入对应的页面。

我尝试了几种方法都不成功。请各位高手帮帮忙。谢谢!

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<ul class="sitemap">
<li id="firstItem" class="primary">
<a href="#">Home</a>
</li>
<xsl:for-each select="node/node">
<li>
<xsl:value-of select="link"/>
</li>
</xsl:for-each>
</ul>
</xsl:template>

</xsl:stylesheet>

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧