root/epidoc2atom/trunk/tei2entry.xsl

Revision 2, 4.3 kB (checked in by thomase, 9 months ago)

get rid of atom: namespace prefixes; closes ticket:3

Line 
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet
3     xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
4    
5     <xsl:output encoding="UTF-8" indent="yes" method="xml"  exclude-result-prefixes="#all"/>
6    
7     <xsl:param name="tagdomain">insaph.kcl.ac.uk</xsl:param>
8     <xsl:param name="tagcommonprefix">iaph2007/</xsl:param>
9     <xsl:param name="tagcommonpostfix"/>
10     <xsl:param name="altdomain">insaph.kcl.ac.uk</xsl:param>
11     <xsl:param name="altcommonpath">iaph2007/</xsl:param>
12     <xsl:param name="altcommonextension">.html</xsl:param>
13     <xsl:param name="updateddate">2008-04-01T00:00:00.1Z</xsl:param>
14    
15     <xsl:template match="/">
16         <xsl:apply-templates/>
17     </xsl:template>
18    
19     <xsl:template match="TEI.2">
20        
21         <!-- get published date, which we'll need both for the id and atom:published -->
22         <xsl:variable name="published">
23             <xsl:for-each select="teiHeader/revisionDesc/change[1]/date[1]">
24                 <xsl:text></xsl:text><xsl:value-of select="."/><xsl:if test="string-length(.) = 10">T00:00:00.1Z</xsl:if><xsl:text></xsl:text>
25             </xsl:for-each>
26         </xsl:variable>
27         <xsl:variable name="tagdate"><xsl:value-of select="substring($published, 1, 10)"/></xsl:variable>
28        
29         <!-- create an atom:entry -->
30         <entry xmlns="http://www.w3.org/2005/Atom">
31             <!-- atom:author and atom:rights -->
32             <xsl:apply-templates select="teiHeader/fileDesc/publicationStmt"/>
33            
34             <id>tag:<xsl:value-of select="$tagdomain"/>,<xsl:value-of select="$tagdate"/>:/<xsl:value-of select="$tagcommonprefix"/><xsl:value-of select="@id"/><xsl:value-of select="$tagcommonpostfix"/></id>
35            
36             <!-- atom:title -->
37             <title><xsl:value-of select="normalize-space(teiHeader/fileDesc/titleStmt/title)"/></title>
38            
39             <xsl:element name="link">
40                 <xsl:attribute name="rel">alternate</xsl:attribute>
41                 <xsl:attribute name="href">http://<xsl:value-of select="$altdomain"/>/<xsl:value-of select="$altcommonpath"/><xsl:value-of select="@id"/><xsl:value-of select="$altcommonextension"/></xsl:attribute>
42             </xsl:element>
43            
44             <published><xsl:value-of select="$published"/></published>
45            
46             <updated><xsl:value-of select="$updateddate"/></updated>
47            
48             <!-- atom:summary -->
49             <xsl:apply-templates select="text"/>
50            
51         </entry>
52     </xsl:template>
53    
54     <xsl:template match="publicationStmt">
55         <xsl:for-each select="descendant::editor">
56             <author xmlns="http://www.w3.org/2005/Atom">
57                 <name><xsl:value-of select="normalize-space(.)"/></name>
58             </author>
59         </xsl:for-each>
60         <xsl:if test="p[not(descendant::editor)]">
61             <rights xmlns="http://www.w3.org/2005/Atom">
62                 <xsl:apply-templates select="p[not(descendant::editor)]" mode="sanitize"/>
63             </rights>
64         </xsl:if>
65     </xsl:template>
66    
67     <xsl:template match="text">
68         <summary type="text" xmlns="http://www.w3.org/2005/Atom">
69             <xsl:text></xsl:text><xsl:apply-templates mode="sanitize" select="descendant::div[@n='monument']/p"/><xsl:text></xsl:text>
70             <xsl:text></xsl:text><xsl:apply-templates mode="sanitize" select="descendant::div[@n='text']/p"/><xsl:text></xsl:text>
71             <xsl:text></xsl:text>Date: <xsl:apply-templates mode="sanitize" select="descendant::div[@n='date']/p"/><xsl:text></xsl:text>
72             <xsl:if test="descendant::div[@n='photographs']"><xsl:text></xsl:text>Photo<xsl:if test="count(descendant::div[@n='photographs']/descendant::figure) &gt; 1">s</xsl:if>.<xsl:text> </xsl:text></xsl:if>
73             <xsl:text></xsl:text><xsl:apply-templates mode="sanitize" select="descendant::div[@n='record']/p"/><xsl:text></xsl:text>
74             <xsl:text></xsl:text><xsl:apply-templates mode="sanitize" select="descendant::div[@type='bibliography']/p"/><xsl:text></xsl:text>
75         </summary>
76     </xsl:template>
77    
78     <xsl:template match="p" mode="sanitize">
79         <xsl:variable name="theval" select="normalize-space(.)"/>
80         <xsl:text></xsl:text><xsl:value-of select="$theval"/><xsl:if test="not(substring($theval,string-length($theval), 1) = '.')">.</xsl:if><xsl:text> </xsl:text>
81     </xsl:template>
82    
83    
84 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.