source: trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/filter.xslt @ 585

Revision 585, 3.9 KB checked in by jojada, 3 years ago (diff)

Do not filter out hyperlink element.

Line 
1<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
2        xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
3        xmlns:o="urn:schemas-microsoft-com:office:office"
4        xmlns:v="urn:schemas-microsoft-com:vml"
5        xmlns:WX="http://schemas.microsoft.com/office/word/2003/auxHint"
6        xmlns:aml="http://schemas.microsoft.com/aml/2001/core"
7        xmlns:w10="urn:schemas-microsoft-com:office:word"
8        xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"         
9        xmlns:msxsl="urn:schemas-microsoft-com:xslt"
10        xmlns:ext="http://www.xmllab.net/wordml2html/ext"
11        xmlns:java="http://xml.apache.org/xalan/java"
12        xmlns:xml="http://www.w3.org/XML/1998/namespace"
13        version="1.0"
14        exclude-result-prefixes="java msxsl ext o v WX aml w10">       
15
16       
17<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" indent="yes" />
18        <!-- doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" -->
19
20<!-- One line for each of the things in FilterSettings -->             
21<xsl:param name="removeProofErrors"/> <!-- select="'passed in'"-->     
22<xsl:param name="removeContentControls"/>
23<xsl:param name="removeRsids"/> 
24<xsl:param name="tidyForDocx4all"/> <!--  this cleans up stuff not specifically supported by docx4all -->       
25               
26<xsl:template match="@*|node()">
27  <xsl:copy>
28    <xsl:apply-templates select="@*|node()"/>
29  </xsl:copy>
30</xsl:template>
31
32<xsl:template match="w:lastRenderedPageBreak">
33       
34        <xsl:choose>
35                <xsl:when test="$tidyForDocx4all=true()">
36                        <!-- ignore it -->
37                </xsl:when>
38                <xsl:otherwise>
39                  <xsl:copy>
40                        <xsl:apply-templates select="@*|node()"/>
41                  </xsl:copy>
42                </xsl:otherwise>
43        </xsl:choose>
44       
45</xsl:template>
46
47<xsl:template match="w:tab">
48       
49        <xsl:choose>
50                <xsl:when test="$tidyForDocx4all=true()">
51                          <!-- ignore it, since replacing with w:t
52                               or <w:t xml:space="preserve"> causes an exception. -->
53                </xsl:when>
54                <xsl:otherwise>
55                  <xsl:copy>
56                        <xsl:apply-templates select="@*|node()"/>
57                  </xsl:copy>
58                </xsl:otherwise>
59        </xsl:choose>
60       
61</xsl:template>
62
63<xsl:template match="w:proofErr">
64       
65        <xsl:choose>
66                <xsl:when test="$removeProofErrors=true()">
67                        <!-- ignore it -->
68                </xsl:when>
69                <xsl:otherwise>
70                  <xsl:copy>
71                        <xsl:apply-templates select="@*|node()"/>
72                  </xsl:copy>
73                </xsl:otherwise>
74        </xsl:choose>
75       
76</xsl:template>
77
78<xsl:template match="w:sdt">
79       
80        <xsl:choose>
81                <xsl:when test="$removeContentControls=true()">
82                        <xsl:apply-templates select="w:sdtContent/*"/>
83                </xsl:when>
84                <xsl:otherwise>
85                  <xsl:copy>
86                        <xsl:apply-templates select="@*|node()"/>
87                  </xsl:copy>
88                </xsl:otherwise>
89        </xsl:choose>
90       
91</xsl:template>
92       
93
94<xsl:template match="@w:rsidRPr | @w:rsidDel | @w:rsidR | @w:rsidSect | @w:rsidTr | @w:rsidP | @w:rsidRDefault | w:rsids | w:rsidRoot | w:rsid  ">
95        <!-- rsids contains rsidRoot and rsid -->
96       
97        <xsl:choose>
98                <xsl:when test="$removeRsids=true()">
99                        <!-- ignore it -->
100                </xsl:when>
101                <xsl:otherwise>
102                  <xsl:copy>
103                        <xsl:apply-templates select="@*|node()"/>
104                  </xsl:copy>
105                </xsl:otherwise>
106        </xsl:choose>
107       
108</xsl:template>
109       
110               
111       
112               
113<!--   
114<xsl:template match="pkg:part[pkg:xmlData/w:document]">
115   <pkg:part>
116        <pkg:xmlData>     
117<w:document>
118                <w:body>
119                    <w:p>
120                        <w:r>
121                            <w:t>Hello World!
122                                                               
123                                                                <xsl:value-of select="$removeProofErrors"/>
124                                                       
125                                                                <xsl:if test="$removeProofErrors=true()">
126                                                                       
127                                                                        Soon, we'll remove proof errors :)
128                                                                       
129                                                                </xsl:if>
130
131                                                                <xsl:if test="$removeProofErrors=false()">
132                                                                       
133                                                                        Who would want to get rid of such things?
134                                                                       
135                                                                </xsl:if>
136
137                                                        </w:t>
138                        </w:r>
139                    </w:p>
140                </w:body>
141            </w:document>       
142        </pkg:xmlData>
143    </pkg:part> 
144</xsl:template>
145-->
146
147
148
149</xsl:stylesheet>
150
Note: See TracBrowser for help on using the repository browser.