My favorites
▼
|
Sign in
lindenb
Pierre Lindenbaum's library
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
src
/
xsl
/
xml2html.xsl
‹r277
r508
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version='1.0' ?>
<xsl:stylesheet
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns="http://www.w3.org/1999/xhtml"
version='1.0'
>
<!--
This stylesheet transform xml to html
-->
<xsl:output method="html"
indent="yes"
omit-xml-declaration="yes"
/>
<xsl:template match="/">
<div style="font-family:monospace;white-space:pre; background-color:rgb(230,230,230);border: 1px solid black;width:100%;height:300px;overflow:auto;">
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template match="text()"><xsl:choose><xsl:when test="string-length(normalize-space(.))>0"><span style="color:gray;"><xsl:value-of select="."/></span></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></xsl:template>
<xsl:template match="@*"><xsl:text> </xsl:text><xsl:value-of select="name()"/>="<span style="color:gray;"><xsl:choose><xsl:when test="starts-with (.,'http://')"><xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute><xsl:value-of select="."/></xsl:element></xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose></span>"</xsl:template>
<xsl:template match="node()" name="element"><xsl:choose>
<xsl:when test="count(child::node()) != 0"><span><<xsl:value-of select="name()"/><xsl:apply-templates select="@*"/>></span><xsl:apply-templates/><span></<xsl:value-of select="name()"/>></span></xsl:when>
<xsl:otherwise><span><<xsl:value-of select="name()"/><xsl:apply-templates select="@*"/>/></span></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="comment()"><span style="color:green;"
><!-- <xsl:value-of select="."/> --></span
></xsl:template>
<xsl:template match="processing-instruction()"><span style="color:blue;"
><?<xsl:value-of select="name()"/><xsl:text> </xsl:text> <xsl:value-of select="."/> ?></span></xsl:template>
</xsl:stylesheet>
Show details
Hide details
Change log
r452
by plindenbaum on Feb 15, 2010
Diff
cont
Go to:
/trunk/src/xsl/xml2html.xsl
Project members,
sign in
to write a code review
Older revisions
r277
by plindenbaum on May 20, 2009
Diff
cont
r248
by plindenbaum on Apr 3, 2009
Diff
cont
r239
by plindenbaum on Mar 7, 2009
Diff
cont
All revisions of this file
File info
Size: 1936 bytes, 47 lines
View raw file
Powered by
Google Project Hosting