- Timestamp:
- 03/26/08 21:03:30 (5 years ago)
- Files:
-
- 1 modified
-
lang/xslt/misc/xml.xsl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/xslt/misc/xml.xsl
r262 r8401 6 6 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 7 7 xmlns:cc="http://web.resource.org/cc/" 8 exclude-result-prefixes="rdf cc" 8 xmlns:my="http://coderepos.org/" 9 exclude-result-prefixes="rdf cc my" 9 10 xml:lang="ja"> 10 11 … … 22 23 23 24 <xsl:strip-space elements="*" /> 25 26 <xsl:template name="my:cho45.css"> 27 <xsl:text><![CDATA[ 28 * { 29 margin: 0; 30 padding: 0; 31 text-decoration: none; 32 font-size: 100%; 33 font-weight: normal; 34 font-style: normal; 35 background: transparent; 36 border: none; 37 } 38 39 body { 40 font-family: "Verdana", "Helvetica", sans-serif; 41 background: #000; 42 color: #fff; 43 padding: 0; 44 margin: 0; 45 line-height: 1.4; 46 } 47 48 h1 { 49 font-size: 100%; 50 background: #c80055; 51 margin: 0; 52 padding: 0.5em; 53 } 54 55 p { 56 margin: 0; 57 } 58 59 #tree { 60 padding: 2em 1em; 61 margin: 0; 62 border-style: solid; 63 border-width: 0 0 0 2em; 64 border-color: #1b261d; 65 } 66 67 #info { 68 background: #c80055; 69 margin: 0 0 0 0; 70 padding: 1em; 71 } 72 73 .paren { 74 color: #72655b; 75 } 76 77 .content { 78 margin: 0 0 0 2em; 79 } 80 81 .ename { 82 color: #c80055; 83 } 84 85 .attrn { 86 color: #ab5a39; 87 } 88 89 .attrv { 90 color: #4e6443; 91 } 92 93 .attrv a { 94 color: #4e6443; 95 text-decoration: none; 96 border-bottom: 1px dotted; 97 } 98 99 .attrv a:hover { 100 color: #4e6443; 101 text-decoration: none; 102 border-bottom: none; 103 } 104 105 .comment { 106 color: #999; 107 } 108 109 .pi { 110 color: #993; 111 } 112 113 .text { 114 color: #70645a; 115 } 116 117 .less { 118 } 119 .less a { 120 } 121 ]]></xsl:text> 122 </xsl:template> 123 24 124 <xsl:template match="/"> 25 125 <html xml:lang="{/*[position() = 1]/@xml:lang}"> … … 31 131 </title> 32 132 <style type="text/css"> 33 <![CDATA[ 34 * { 35 margin: 0; 36 padding: 0; 37 text-decoration: none; 38 font-size: 100%; 39 font-weight: normal; 40 font-style: normal; 41 background: transparent; 42 border: none; 43 } 44 45 body { 46 font-family: "Verdana", "Helvetica", sans-serif; 47 background: #000; 48 color: #fff; 49 padding: 0; 50 margin: 0; 51 line-height: 1.4; 52 } 53 54 h1 { 55 font-size: 100%; 56 background: #c80055; 57 margin: 0; 58 padding: 0.5em; 59 } 60 61 p { 62 margin: 0; 63 } 64 65 #tree { 66 padding: 2em 1em; 67 margin: 0; 68 border-style: solid; 69 border-width: 0 0 0 2em; 70 border-color: #1b261d; 71 } 72 73 #info { 74 background: #c80055; 75 margin: 0 0 0 0; 76 padding: 1em; 77 } 78 79 .paren { 80 color: #72655b; 81 } 82 83 .content { 84 margin: 0 0 0 2em; 85 } 86 87 .ename { 88 color: #c80055; 89 } 90 91 .attrn { 92 color: #ab5a39; 93 } 94 95 .attrv { 96 color: #4e6443; 97 } 98 99 .attrv a { 100 color: #4e6443; 101 text-decoration: none; 102 border-bottom: 1px dotted; 103 } 104 105 .attrv a:hover { 106 color: #4e6443; 107 text-decoration: none; 108 border-bottom: none; 109 } 110 111 .comment { 112 color: #999; 113 } 114 115 .pi { 116 color: #993; 117 } 118 119 .text { 120 color: #70645a; 121 } 122 123 .less { 124 } 125 .less a { 126 } 127 ]]> 133 <xsl:call-template name="my:cho45.css"/> 128 134 </style> 129 135 </head> … … 138 144 </h1> 139 145 <div id="tree"> 140 <xsl:apply-templates />146 <xsl:apply-templates mode="my:tree.xhtml"/> 141 147 </div> 142 148 <div id="info"> … … 163 169 <!-- msxml は空白にうるさいので少し見にくい。 --> 164 170 165 <xsl:template match="*" >171 <xsl:template match="*" mode="my:tree.xhtml"> 166 172 <div class="element"> 167 173 <xsl:choose> 168 174 <xsl:when test=". = '' and count(*) = 0"> 169 <span class="paren"><</span><span class="ename"><xsl:value-of select="name()" /></span><xsl:apply-templates select="@*"/><span class="paren">/></span> 175 <span class="paren"><</span><span class="ename"><xsl:value-of select="name()" /></span> 176 <xsl:apply-templates select="@*" mode="my:tree.xhtml"/> 177 <span class="paren">/></span> 170 178 </xsl:when> 171 179 <xsl:otherwise> 172 <span class="paren"><</span><span class="ename"><xsl:value-of select="name()" /></span><xsl:apply-templates select="@*"/><span class="paren">></span> 180 <span class="paren"><</span> 181 <span class="ename"><xsl:value-of select="name()" /></span> 182 <xsl:apply-templates select="@*" mode="my:tree.xhtml"/> 183 <span class="paren">></span> 173 184 <xsl:choose> 174 185 <xsl:when test="string-length() < $shortlen and count(*) = 0"> 175 <xsl:apply-templates />186 <xsl:apply-templates mode="my:tree.xhtml"/> 176 187 </xsl:when> 177 188 <xsl:otherwise> 178 189 <div class="content"> 179 <xsl:apply-templates />190 <xsl:apply-templates mode="my:tree.xhtml"/> 180 191 </div> 181 192 </xsl:otherwise> … … 187 198 </xsl:template> 188 199 189 <xsl:template match="@*" >200 <xsl:template match="@*" mode="my:tree.xhtml"> 190 201 <xsl:text> </xsl:text> 191 202 <span class="attrn"> 192 203 <xsl:value-of select="name()" /> 193 204 <xsl:text>=</xsl:text> 194 </span><span class="attrv"> 205 </span> 206 <span class="attrv"> 195 207 <xsl:text>"</xsl:text> 196 208 <xsl:choose> … … 200 212 local-name() = 'resource' or 201 213 local-name() = 'about'"> 202 <a href="{.}"><xsl:call-template name="entity"><xsl:with-param name="string" select="."/></xsl:call-template></a> 214 <a href="{.}"> 215 <xsl:call-template name="my:entity"> 216 <xsl:with-param name="string" select="."/> 217 </xsl:call-template> 218 </a> 203 219 </xsl:when> 204 220 <xsl:otherwise> 205 <xsl:call-template name="entity"><xsl:with-param name="string" select="."/></xsl:call-template> 221 <xsl:call-template name="my:entity"> 222 <xsl:with-param name="string" select="."/> 223 </xsl:call-template> 206 224 </xsl:otherwise> 207 225 </xsl:choose> 208 <xsl:text>"</xsl:text></span> 209 </xsl:template> 210 211 <xsl:template match="comment()"> 226 <xsl:text>"</xsl:text> 227 </span> 228 </xsl:template> 229 230 <xsl:template match="comment()" mode="my:tree.xhtml"> 212 231 <div class="element comment"> 213 <xsl:text><!--</xsl:text><xsl:value-of select="."/><xsl:text>--></xsl:text> 232 <xsl:text><!--</xsl:text> 233 <xsl:value-of select="."/> 234 <xsl:text>--></xsl:text> 214 235 </div> 215 236 </xsl:template> 216 237 217 <xsl:template match="processing-instruction()" >238 <xsl:template match="processing-instruction()" mode="my:tree.xhtml"> 218 239 <div class="element pi"> 219 <xsl:text><?</xsl:text><xsl:value-of select="name()" /><xsl:text> </xsl:text><xsl:value-of select="."/><xsl:text>?></xsl:text> 240 <xsl:text><?</xsl:text> 241 <xsl:value-of select="name()" /> 242 <xsl:text> </xsl:text> 243 <xsl:value-of select="."/> 244 <xsl:text>?></xsl:text> 220 245 </div> 221 246 </xsl:template> 222 247 223 <xsl:template match="text()"> 224 <span class="text"><xsl:call-template name="entity"><xsl:with-param name="string" select="."/></xsl:call-template></span> 248 <xsl:template match="text()" mode="my:tree.xhtml"> 249 <span class="text"> 250 <xsl:call-template name="my:entity"> 251 <xsl:with-param name="string" select="."/> 252 </xsl:call-template> 253 </span> 225 254 </xsl:template> 226 255 227 256 <!-- & > < 変換 --> 228 <xsl:template name=" entity">257 <xsl:template name="my:entity"> 229 258 <xsl:param name="string" /> 230 259 <xsl:choose> 231 260 <xsl:when test="contains($string, '&')"> 232 <xsl:call-template name=" entity2">261 <xsl:call-template name="my:entity2"> 233 262 <xsl:with-param name="string" select="substring-before($string, '&')" /> 234 263 </xsl:call-template> 235 <xsl:text>&amp;</xsl:text><xsl:call-template name="entity"> 264 <xsl:text>&amp;</xsl:text> 265 <xsl:call-template name="my:entity"> 236 266 <xsl:with-param name="string" select="substring-after($string, '&')" /> 237 267 </xsl:call-template> 238 268 </xsl:when> 239 269 <xsl:otherwise> 240 <xsl:call-template name=" entity2">270 <xsl:call-template name="my:entity2"> 241 271 <xsl:with-param name="string" select="$string" /> 242 272 </xsl:call-template> … … 245 275 </xsl:template> 246 276 247 <xsl:template name=" entity2">277 <xsl:template name="my:entity2"> 248 278 <xsl:param name="string" /> 249 279 <xsl:choose> … … 253 283 <xsl:if test="contains($string, '<')"> 254 284 <xsl:variable name="nstr"><xsl:value-of select="substring-before($string, '<')"/><xsl:text>&lt;</xsl:text><xsl:value-of select="substring-after($string, '<')"/></xsl:variable> 255 <xsl:call-template name=" entity2">285 <xsl:call-template name="my:entity2"> 256 286 <xsl:with-param name="string" select="$nstr"/> 257 287 </xsl:call-template> … … 261 291 <xsl:if test="contains($string, '>')"> 262 292 <xsl:variable name="nstr"><xsl:value-of select="substring-before($string, '>')"/><xsl:text>&gt;</xsl:text><xsl:value-of select="substring-after($string, '>')"/></xsl:variable> 263 <xsl:call-template name=" entity2">293 <xsl:call-template name="my:entity2"> 264 294 <xsl:with-param name="string" select="$nstr"/> 265 295 </xsl:call-template>
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)