|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> |
|
3 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
4 <!-- This component and the accompanying materials are made available under the terms of the License |
|
5 "Eclipse Public License v1.0" which accompanies this distribution, |
|
6 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
7 <!-- Initial Contributors: |
|
8 Nokia Corporation - initial contribution. |
|
9 Contributors: |
|
10 --> |
|
11 <xsl:param name="datetime"/> |
|
12 <xsl:param name="sourceFile"/> |
|
13 <xsl:param name="sourceDir"/> |
|
14 |
|
15 <xsl:output method="xml" indent="no"/> |
|
16 <xsl:include href="apiref.xsl"/> |
|
17 <xsl:include href="cxx.xsl"/> |
|
18 <!-- Start required cleanup stuff--> |
|
19 <xsl:template match="*" name="wrapInRequiredCleanup" priority="-1"> |
|
20 <xsl:comment> |
|
21 <xsl:text/><required-cleanup class="fail" remap="<xsl:value-of select="name()"/>"<xsl:apply-templates select="@*" mode="serialize"/>><xsl:text/> |
|
22 <xsl:apply-templates mode="serialize"/> |
|
23 <xsl:text/></required-cleanup<xsl:text/> |
|
24 </xsl:comment> |
|
25 </xsl:template> |
|
26 <xsl:template match="text()" name="serialize-text" mode="serialize"> |
|
27 <xsl:param name="text" select="."/> |
|
28 <xsl:choose> |
|
29 <xsl:when test="contains($text, '--')"> |
|
30 <xsl:value-of select="substring-before($text, '--')"/> |
|
31 <xsl:text>- -</xsl:text> |
|
32 <xsl:call-template name="serialize-text"> |
|
33 <xsl:with-param name="text" select="substring-after($text, '--')"/> |
|
34 </xsl:call-template> |
|
35 </xsl:when> |
|
36 <xsl:otherwise> |
|
37 <xsl:value-of select="$text"/> |
|
38 </xsl:otherwise> |
|
39 </xsl:choose> |
|
40 </xsl:template> |
|
41 <xsl:template match="*" mode="serialize"> |
|
42 <xsl:text><</xsl:text> |
|
43 <xsl:value-of select="name()"/> |
|
44 <xsl:apply-templates select="@*" mode="serialize"/> |
|
45 <xsl:text>></xsl:text> |
|
46 <xsl:apply-templates select="node()" mode="serialize"/> |
|
47 <xsl:text></</xsl:text> |
|
48 <xsl:value-of select="name()"/> |
|
49 <xsl:text>></xsl:text> |
|
50 </xsl:template> |
|
51 <xsl:template match="@*" mode="serialize"> |
|
52 <xsl:text/> |
|
53 <xsl:value-of select="name()"/> |
|
54 <xsl:text>="</xsl:text> |
|
55 <xsl:call-template name="serialize-text"/> |
|
56 <xsl:text>"</xsl:text> |
|
57 </xsl:template> |
|
58 <!-- End required cleanup stuff--> |
|
59 |
|
60 <!-- Start Doctype--> |
|
61 <xsl:template name="outputDoctype"> |
|
62 <xsl:param name="topicType"/> |
|
63 <xsl:choose> |
|
64 <xsl:when test="normalize-space($topicType) = 'map'"> |
|
65 <xsl:text disable-output-escaping="yes"> |
|
66 <![CDATA[<!DOCTYPE map PUBLIC "-//OASIS//DTD DITA Map//EN" "map.dtd">]]> |
|
67 </xsl:text> |
|
68 </xsl:when> |
|
69 <xsl:when test="normalize-space($topicType) = 'topic'"> |
|
70 <xsl:text disable-output-escaping="yes"> |
|
71 <![CDATA[<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">]]> |
|
72 </xsl:text> |
|
73 </xsl:when> |
|
74 <xsl:when test="normalize-space($topicType) = 'concept'"> |
|
75 <xsl:text disable-output-escaping="yes"> |
|
76 <![CDATA[<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">]]> |
|
77 </xsl:text> |
|
78 </xsl:when> |
|
79 <xsl:when test="normalize-space($topicType) = 'reference'"> |
|
80 <xsl:text disable-output-escaping="yes"> |
|
81 <![CDATA[<!DOCTYPE reference PUBLIC "-//OASIS//DTD DITA Reference//EN" "reference.dtd">]]> |
|
82 </xsl:text> |
|
83 </xsl:when> |
|
84 <xsl:when test="normalize-space($topicType) = 'task'"> |
|
85 <xsl:text disable-output-escaping="yes"> |
|
86 <![CDATA[<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">]]> |
|
87 </xsl:text> |
|
88 </xsl:when> |
|
89 <xsl:otherwise> |
|
90 <xsl:text disable-output-escaping="yes"> |
|
91 <![CDATA[<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">]]> |
|
92 </xsl:text> |
|
93 </xsl:otherwise> |
|
94 </xsl:choose> |
|
95 </xsl:template> |
|
96 <xsl:template match="/"> |
|
97 <xsl:choose> |
|
98 <xsl:when test="name(/*)='topic'"> |
|
99 <xsl:call-template name="outputDoctype"> |
|
100 <xsl:with-param name="topicType" select="'topic'"/> |
|
101 </xsl:call-template> |
|
102 </xsl:when> |
|
103 <xsl:when test="name(/*)='cxxAPIMap'"> |
|
104 <xsl:call-template name="outputDoctype"> |
|
105 <xsl:with-param name="topicType" select="'map'"/> |
|
106 </xsl:call-template> |
|
107 </xsl:when> |
|
108 <xsl:otherwise> |
|
109 <xsl:call-template name="outputDoctype"> |
|
110 <xsl:with-param name="topicType" select="'reference'"/> |
|
111 </xsl:call-template> |
|
112 </xsl:otherwise> |
|
113 </xsl:choose> |
|
114 <xsl:apply-templates/> |
|
115 </xsl:template> |
|
116 |
|
117 <xsl:template match="@*"> |
|
118 <xsl:copy-of select="."/> |
|
119 </xsl:template> |
|
120 |
|
121 <xsl:template match="@id"> |
|
122 <xsl:variable name="thisId" select="."/> |
|
123 <xsl:choose> |
|
124 <xsl:when test="count(//*[@id=$thisId]) > 1"> |
|
125 <xsl:attribute name="id"><xsl:value-of select="generate-id(.)"/></xsl:attribute> |
|
126 </xsl:when> |
|
127 <xsl:otherwise> |
|
128 <xsl:copy-of select="."/> |
|
129 </xsl:otherwise> |
|
130 </xsl:choose> |
|
131 |
|
132 </xsl:template> |
|
133 |
|
134 <xsl:template match="*" priority="-0.75"> |
|
135 <!-- If this element begins with cxx wrap it in a required cleanup |
|
136 if no its probably standard dita--> |
|
137 <xsl:choose> |
|
138 <xsl:when test="starts-with(name(.),'cxx')"> |
|
139 <xsl:comment>An element was found that does not yet have a lineage DITA defined</xsl:comment> |
|
140 <xsl:call-template name="wrapInRequiredCleanup"/> |
|
141 </xsl:when> |
|
142 <xsl:otherwise> |
|
143 <xsl:copy-of select="."/> |
|
144 </xsl:otherwise> |
|
145 </xsl:choose> |
|
146 |
|
147 </xsl:template> |
|
148 |
|
149 </xsl:stylesheet> |