blob: 0c6a17efba6ce257d59a8caab4e89b5d426b1524 (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?xml version="1.0" encoding="utf-8"?>
<!-- Doc Studio Contents to HTML Help Compiler Contents Transform
Invoke with: xsltransform TocToChmContents.xsl toc.xml [/arg:html=html-dir] /out:output.hhc
- comments - specifies the directory where the HTML files are stored.
NOTE: The output looks like HTML, but it isn't. Whitespace is significant.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5">
<msxsl:script language="C#" implements-prefix="ddue">
<msxsl:using namespace="System.Xml" />
<msxsl:using namespace="System.Xml.XPath" />
<![CDATA[
public static string getTitle(string fileName) {
XPathDocument doc = new XPathDocument(fileName);
XPathNavigator node = doc.CreateNavigator().SelectSingleNode("/html/head/title");
if (node != null)
return node.Value;
else
return String.Empty;
}
]]>
</msxsl:script>
<xsl:param name="html" select="string('Output/html')"/>
<xsl:output method="text" encoding="utf-8"/>
<xsl:template match="/">
<xsl:text><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML/EN">
</xsl:text>
<xsl:text><HTML>
</xsl:text>
<xsl:text> <BODY>
</xsl:text>
<xsl:apply-templates select="topics"/>
<xsl:text> </BODY>
</xsl:text>
<xsl:text></HTML>
</xsl:text>
</xsl:template>
<xsl:template match="topics">
<xsl:call-template name="parentNode"/>
</xsl:template>
<xsl:template name="parentNode">
<xsl:if test="topic">
<xsl:call-template name="indent"/>
<xsl:text><UL>
</xsl:text>
<xsl:apply-templates select="topic"/>
<xsl:call-template name="indent"/>
<xsl:text></UL>
</xsl:text>
</xsl:if>
</xsl:template>
<xsl:template match="topic">
<xsl:call-template name="indent"/>
<xsl:text><![CDATA[<LI><OBJECT type="text/sitemap">]]>
</xsl:text>
<xsl:call-template name="indent"/>
<xsl:text> <param name="Name" value="</xsl:text>
<xsl:value-of select="ddue:getTitle(concat($html,'/', @file, '.htm'))"/>
<xsl:text>">
</xsl:text>
<xsl:call-template name="indent"/>
<xsl:text> <param name="Local" value="html\</xsl:text>
<xsl:value-of select="@file"/>
<xsl:text>.htm">
</xsl:text>
<xsl:call-template name="indent"/>
<xsl:text><![CDATA[</OBJECT></LI>]]>
</xsl:text>
<xsl:call-template name="parentNode"/>
</xsl:template>
<xsl:template name="indent"><xsl:for-each select="ancestor::*"><xsl:text>  </xsl:text></xsl:for-each></xsl:template>
</xsl:stylesheet>
|