xslt_bbs.xml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  2. <xsl:template match="/">
  3. <论坛列表>
  4. <xsl:apply-templates select="//*[@id='forum']/table/tbody/tr[position()>=1 and count(.//*[@class='topic']/a/text())>0]" mode="论坛列表"/>
  5. </论坛列表>
  6. </xsl:template>
  7. <xsl:template match="//*[@id='forum']/table/tbody/tr[position()>=1 and count(.//*[@class='topic']/a/text())>0]" mode="论坛列表">
  8. <item>
  9. <标题>
  10. <xsl:value-of select="*//*[@class='topic']/a/text()"/>
  11. <xsl:value-of select="*[@class='topic']/a/text()"/>
  12. <xsl:if test="@class='topic'">
  13. <xsl:value-of select="a/text()"/>
  14. </xsl:if>
  15. </标题>
  16. <发帖人>
  17. <xsl:value-of select="*//*[@class='created']/text()[position()=2]"/>
  18. <xsl:value-of select="*[@class='created']/text()[position()=2]"/>
  19. <xsl:if test="@class='created'">
  20. <xsl:value-of select="text()[position()=2]"/>
  21. </xsl:if>
  22. </发帖人>
  23. <帖子详细链接>
  24. <xsl:value-of select="*//*[@class='topic']/a/@href"/>
  25. <xsl:value-of select="*[@class='topic']/a/@href"/>
  26. <xsl:if test="@class='topic'">
  27. <xsl:value-of select="a/@href"/>
  28. </xsl:if>
  29. </帖子详细链接>
  30. <回复数>
  31. <xsl:value-of select="*//*[@class='replies']/text()"/>
  32. <xsl:value-of select="*[@class='replies']/text()"/>
  33. <xsl:if test="@class='replies'">
  34. <xsl:value-of select="text()"/>
  35. </xsl:if>
  36. </回复数>
  37. <发帖时间>
  38. <xsl:value-of select="*//*[@class='created']/text()[position()=1]"/>
  39. <xsl:value-of select="*[@class='created']/text()[position()=1]"/>
  40. <xsl:if test="@class='created'">
  41. <xsl:value-of select="text()[position()=1]"/>
  42. </xsl:if>
  43. </发帖时间>
  44. <最后回复时间>
  45. <xsl:value-of select="*//*[@class='last-reply active']/text()[position()=1]"/>
  46. <xsl:value-of select="*[@class='last-reply active']/text()[position()=1]"/>
  47. <xsl:if test="@class='last-reply active'">
  48. <xsl:value-of select="text()[position()=1]"/>
  49. </xsl:if>
  50. </最后回复时间>
  51. </item>
  52. </xsl:template>
  53. </xsl:stylesheet>