-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxml2html.xsl
53 lines (39 loc) · 1.01 KB
/
xml2html.xsl
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
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:h="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="h"
>
<xsl:output method="html" indent="no"/>
<xsl:template match="*|@*|processing-instruction()">
<xsl:copy>
<xsl:apply-templates select="*|@*|processing-instruction()|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="h:body">
<body>
<xsl:copy><xsl:apply-templates select="@*"/></xsl:copy>
<xsl:apply-templates/>
<h2>List of links</h2>
<xsl:for-each select="//h:a[@href]">
<xsl:text>[</xsl:text>
<xsl:number level="any"/>
<xsl:text>] </xsl:text> <xsl:value-of select="@href"/>
<br/>
</xsl:for-each>
</body>
</xsl:template>
<xsl:template match="h:a">
<a>
<xsl:copy><xsl:apply-templates select="@*"/></xsl:copy>
<xsl:apply-templates/>
</a>
<xsl:if test="@href">
<xsl:text>[</xsl:text>
<xsl:number level="any"/>
<xsl:text>]</xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>