topical media & game development

talk show tell print

basic-xml-13-version.xsl / xsl



  <xsl:stylesheet version="1.0"  
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
      xmlns:rss="http://purl.org/rss/1.0/"
      xmlns:foaf="http://xmlns.com/foaf/0.1/"
      xmlns:atom="http://purl.org/atom/ns#"> 
  
  <xsl:output method="text" indent="yes"/>  
  
  <xsl:template match="/">
      <xsl:text>&#xA;</xsl:text>
      <xsl:apply-templates />
      <xsl:text>&#xA;</xsl:text>
  </xsl:template>
  
  <xsl:template match="/rss">
      <xsl:text>RSS Version: </xsl:text>
      <xsl:value-of select="./@version" />
      <xsl:apply-templates select="channel/title" />
  </xsl:template>
  
  <xsl:template match="/atom:feed">
      <xsl:text>Atom Version: </xsl:text>
      <xsl:value-of select="./@version" />
      <xsl:apply-templates  select="atom:title"/>
  </xsl:template>
  
  <xsl:template match="/rdf:RDF">
  (RDF)    
  <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="rss:channel">
      <xsl:text>RSS Version: 1.0</xsl:text>
      <xsl:apply-templates />
  </xsl:template>
  
  <xsl:template match="rss:title | atom:title | title">
          <xsl:text>&#xA;Title: </xsl:text>
          <xsl:value-of select="text()" />
  </xsl:template>
  
  <xsl:template match="//*[position() = 1]/foaf:Person/foaf:name">
      <xsl:text>FOAF Name: </xsl:text>
      <xsl:value-of select="text()" />
  </xsl:template>
  
  <xsl:template match="rss:item | text()" />
  
  </xsl:stylesheet>


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.