User Tools

Site Tools


xml

XML

XSLT

Example: Fetch subversion repository log as XML and transform with XSLT into HMTL

svn log -r757:750 --xml >revisions.log.xml

Output XML:

revisions.log.xml
<?xml version="1.0"?>
<log>
  <logentry revision="757">
    <author>dataghost</author>
    <date>2010-11-18T16:46:20.194195Z</date>
    <msg>added French translation based on 0.0.5 (by Edgar/Ed)</msg>
    </logentry>
 
    ...
</log>

Test: Add reference to stylesheet into XML-document and view with firefox:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="svnlog.xsl"?>
...

XSLT:

svnlog.xsl
<?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="/">
  <html>
  <body>
  <h2>Repository log</h2>
  <table border="1">
    <tr bgcolor="#9acd32">
      <th>Status</th>
      <th>Revision</th>
      <th>Message</th>
      <th>Author</th>
      <th>Date</th>
    </tr>
    <xsl:for-each select="log/logentry">
    <tr>
      <td align="center"><input type="checkbox"/></td>
      <td align="center"><xsl:value-of select="@revision"/></td>
      <td><xsl:value-of select="msg"/></td>
      <td><xsl:value-of select="author"/></td>
      <td><xsl:value-of select="date"/></td>
    </tr>
    </xsl:for-each>
  </table>
  </body>
  </html>
</xsl:template>
 
</xsl:stylesheet>

Process:

xsltproc svnlog.xsl revisions.log.xml >revisions.html
xml.txt · Last modified: 2010-11-20 07:11 CET by dominik