helpers/mimeXhtmlPart.xsl
author František Kučera <franta-hg@frantovo.cz>
Mon, 17 Oct 2011 00:55:48 +0200
changeset 85 a76b94bcec92
parent 83 668014315a54
child 88 cbf1a1153313
permissions -rwxr-xr-x
Drupal: oprava XHTML šablony: žádné zdvojování značek.
     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 	
   114 	<!-- Další povolené značky – ostatní odfiltrujeme (zbude z nich jen text) -->
   115 	<xsl:template match="*">
   116 		<xsl:choose>		
   117 			<xsl:when test="
   118 				name() = 'h1' or
   119 				name() = 'h2' or
   120 				name() = 'h3' or
   121 				name() = 'h4' or
   122 				name() = 'h5' or
   123 				name() = 'h6' or
   124 				name() = 'p' or
   125 				name() = 'div' or
   126 				name() = 'br' or
   127 				name() = 'strong' or
   128 				name() = 'em' or
   129 				name() = 'sub' or
   130 				name() = 'sup' or
   131 				name() = 'del' or
   132 				name() = 'ul' or
   133 				name() = 'ol' or
   134 				name() = 'li' or
   135 				name() = 'pre' or
   136 				name() = 'code' or
   137 				name() = 'blockquote'">
   138 				<xsl:element name="{name()}">
   139 					<xsl:copy-of select="./node()"/>
   140 				</xsl:element>
   141 			</xsl:when>
   142 			<xsl:otherwise>
   143 				<xsl:apply-templates/>
   144 			</xsl:otherwise>
   145 		</xsl:choose>		
   146     </xsl:template>
   147 	
   148 </xsl:stylesheet>