recurse_ant_to_html.xsl 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:xs="http://www.w3.org/2001/XMLSchema"
  4. exclude-result-prefixes="xs"
  5. version="2.0">
  6. <xsl:output indent="yes"/>
  7. <xsl:strip-space elements="*"/>
  8. <xsl:template match="*">
  9. <html>
  10. <body>
  11. <xsl:apply-templates mode="child"/>
  12. </body>
  13. </html>
  14. </xsl:template>
  15. <xsl:template mode="child" match="*">
  16. <xsl:choose>
  17. <xsl:when test="./*">
  18. <table border="1">
  19. <tr><td>
  20. <table border="1">
  21. <tr>
  22. <xsl:for-each select="*[ not( child::node()/*) and string-length(text()) &gt;0]">
  23. <td><xsl:value-of select="name()"/></td>
  24. </xsl:for-each>
  25. </tr>
  26. <tr>
  27. <xsl:for-each select="*[ not( child::node()/*) and string-length(text()) &gt;0]">
  28. <td><xsl:value-of select="."/></td>
  29. </xsl:for-each>
  30. </tr>
  31. </table>
  32. </td></tr>
  33. <tr><td><xsl:apply-templates mode="child"/></td></tr>
  34. </table>
  35. </xsl:when>
  36. <xsl:otherwise>
  37. <!--<table>
  38. <tr><td>
  39. <table>
  40. <tr>
  41. <xsl:for-each select=".[ not( child::node()/*)]">
  42. <td><xsl:value-of select="name()"/></td>
  43. </xsl:for-each>
  44. </tr>
  45. <tr>
  46. <xsl:for-each select=".[ not( child::node()/*)]">
  47. <td><xsl:value-of select="."/></td>
  48. </xsl:for-each>
  49. </tr>
  50. </table>
  51. </td></tr>
  52. </table>-->
  53. </xsl:otherwise>
  54. </xsl:choose>
  55. </xsl:template>
  56. </xsl:stylesheet>