helpers/mimeXhtmlPart.xsl
author František Kučera <franta-hg@frantovo.cz>
Mon Oct 17 21:11:59 2011 +0200 (2011-10-17)
changeset 93 3009cb0be547
parent 88 cbf1a1153313
child 94 8c5867ac69df
permissions -rwxr-xr-x
Drupal: text/plain – odkazy budou označené 'apostrofy' místo "uvozovkami".
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <xsl:stylesheet version="2.0"
     3 	xmlns="http://www.w3.org/1999/xhtml"
     4 	xmlns:h="http://www.w3.org/1999/xhtml"
     5 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     6 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
     7 	xmlns:svg="http://www.w3.org/2000/svg"
     8 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
     9 	exclude-result-prefixes="fn h xs">
    10 	<xsl:output 
    11 		method="xml" 
    12 		indent="yes" 
    13 		encoding="UTF-8"		
    14 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"/><!-- 
    15 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>-->
    16 	
    17 		
    18 	<xsl:param name="title"/>
    19 	<xsl:param name="headComment"/>
    20 	<xsl:param name="isRoot"/>
    21 	<xsl:param name="urlBase"/>
    22 	<xsl:param name="wwwRead"/>
    23 	<xsl:param name="wwwPost"/>
    24 	
    25 	
    26 	<!-- Celý dokument -->
    27 	<xsl:template match="/">
    28 		<html>
    29 			<head>
    30 				<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    31 				<xsl:if test="$urlBase">
    32 					<base href="{$urlBase}"/>
    33 				</xsl:if>
    34 				<xsl:if test="$title">
    35 					<title><xsl:value-of select="$title"/></title>
    36 				</xsl:if>
    37 				<xsl:if test="$headComment">
    38 					<xsl:comment><xsl:value-of select="$headComment"/></xsl:comment>
    39 				</xsl:if>
    40 				<style type="text/css">
    41 					body {
    42 						font-family: sans-serif;
    43 						font-size: 16px;
    44 					}
    45 					
    46 					.wwwLinks {
    47 						border-top: 2px solid grey;
    48 						margin-top: 16px;
    49 						font-size: 66%;
    50 					}
    51 					
    52 					blockquote {
    53 						background-color: #eee;
    54 						font-style: italic;
    55 						padding: 2px 20px;
    56 						margin: 10px 32px;
    57 						border-left: 3px solid silver;
    58 					}
    59 					
    60 					pre {
    61 						background-color: #eee;
    62 						padding: 2px 20px;
    63 						margin: 10px 32px;
    64 						border-left: 3px solid #a00;
    65 					}
    66 					
    67 					img {
    68 						margin: 8px;
    69 					}
    70 					
    71 					a img {
    72 						border: none;
    73 					}
    74 				</style>
    75 			</head>
    76 			<body>
    77 				<xsl:if test="$title and $isRoot">
    78 					<h1><xsl:value-of select="$title"/></h1>			
    79 				</xsl:if>
    80 								
    81 				<xsl:apply-templates select="h:html/h:body"/>
    82 				
    83 				<xsl:if test="$wwwRead or $wwwPost">
    84 					<div class="wwwLinks">
    85 						<p>Přístup přes síť www:</p>
    86 						<ul>
    87 							<xsl:if test="$wwwRead"><li><a href="{$wwwRead}">číst tento příspěvek</a></li></xsl:if>
    88 							<xsl:if test="$wwwPost"><li><a href="{$wwwPost}">odpovědět na tento příspěvek</a></li></xsl:if>
    89 						</ul>
    90 					</div>
    91 				</xsl:if>
    92 			</body>
    93 		</html>
    94 	</xsl:template>
    95 	
    96 	
    97 	<!-- Odkazy -->
    98 	<xsl:template match="h:a">
    99 		<a href="{@href}" title="{@title}"><xsl:apply-templates/></a>
   100 	</xsl:template>
   101 	
   102 	
   103 	<!-- Obrázky -->
   104 	<xsl:template match="h:img">
   105 		<img src="{@src}" alt="{@alt}" title="{@title}"><xsl:apply-templates/></img>
   106 	</xsl:template>
   107 	
   108 	<!-- Zkratky -->
   109 	<xsl:template match="h:abbr">
   110 		<abbr title="{@title}"><xsl:apply-templates/></abbr>
   111 	</xsl:template>
   112 	
   113 	<xsl:template match="h:blockquote[not(h:p)]">
   114 		<blockquote>
   115 			<p>
   116 				<xsl:copy-of select="node()"/>
   117 			</p>
   118 		</blockquote>
   119 	</xsl:template>
   120 	
   121 	
   122 	<!-- Další povolené značky – ostatní odfiltrujeme (zbude z nich jen text) -->
   123 	<xsl:template match="*">
   124 		<xsl:choose>		
   125 			<xsl:when test="
   126 				name() = 'h1' or
   127 				name() = 'h2' or
   128 				name() = 'h3' or
   129 				name() = 'h4' or
   130 				name() = 'h5' or
   131 				name() = 'h6' or
   132 				name() = 'p' or
   133 				name() = 'div' or
   134 				name() = 'br' or
   135 				name() = 'hr' or
   136 				name() = 'strong' or
   137 				name() = 'em' or
   138 				name() = 'sub' or
   139 				name() = 'sup' or
   140 				name() = 'del' or
   141 				name() = 'ul' or
   142 				name() = 'ol' or
   143 				name() = 'li' or
   144 				name() = 'pre' or
   145 				name() = 'code' or
   146 				name() = 'blockquote'">
   147 				<xsl:element name="{name()}">
   148 					<xsl:copy-of select="./node()"/>
   149 				</xsl:element>
   150 			</xsl:when>
   151 			<xsl:otherwise>
   152 				<xsl:apply-templates/>
   153 			</xsl:otherwise>
   154 		</xsl:choose>		
   155     </xsl:template>
   156 	
   157 </xsl:stylesheet>