User Tools

Site Tools


xml

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

xml [2010-11-20 07:11 CET] (current)
dominik created
Line 1: Line 1:
 +====== XML ======
  
 +===== XSLT =====
 +
 +[[http://​www.w3schools.com/​xsl/​xsl_transformation.asp|w3schools XSLT - Transformation]]
 +
 +
 +==== Example: Fetch subversion repository log as XML and transform with XSLT into HMTL ====
 +
 +  svn log -r757:750 --xml >​revisions.log.xml
 +
 +Output XML:
 +<file 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>​
 +</​file>​
 +
 +
 +Test: Add reference to stylesheet into XML-document and view with firefox:
 +<code xml>
 +<?xml version="​1.0"?>​
 +<?​xml-stylesheet type="​text/​xsl"​ href="​svnlog.xsl"?>​
 +...
 +</​code>​
 +
 +XSLT:
 +<file xml 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>​
 +</​file>​
 +
 +Process:
 +  xsltproc svnlog.xsl revisions.log.xml >​revisions.html
xml.txt · Last modified: 2010-11-20 07:11 CET by dominik