Ignore:
Timestamp:
05/02/08 07:35:53 (4 years ago)
Author:
jharrop
Message:

Add tidyForDocx4all option to filter.

Location:
trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/WordprocessingMLPackage.java

    r323 r356  
    616616                } 
    617617                 
     618                Boolean tidyForDocx4all = Boolean.FALSE;                 
     619                public void setTidyForDocx4all(boolean val) { 
     620                        tidyForDocx4all = new Boolean(val); 
     621                } 
     622                 
     623                 
    618624                Map<String, Object> getSettings() { 
    619625                        Map<String, Object> settings = new java.util.HashMap<String, Object>(); 
     
    622628                        settings.put("removeContentControls", removeContentControls); 
    623629                        settings.put("removeRsids", removeRsids); 
    624                          
    625                          
     630                        settings.put("tidyForDocx4all", tidyForDocx4all); 
    626631                         
    627632                        return settings; 
  • trunk/docx4j/src/main/java/org/docx4j/openpackaging/packages/filter.xslt

    r323 r356  
    1010        xmlns:ext="http://www.xmllab.net/wordml2html/ext" 
    1111        xmlns:java="http://xml.apache.org/xalan/java" 
     12        xmlns:xml="http://www.w3.org/XML/1998/namespace" 
    1213        version="1.0" 
    13         exclude-result-prefixes="java msxsl ext w o v WX aml w10">       
     14        exclude-result-prefixes="java msxsl ext o v WX aml w10">         
    1415 
    1516         
     
    2122<xsl:param name="removeContentControls"/> 
    2223<xsl:param name="removeRsids"/>  
    23          
     24<xsl:param name="tidyForDocx4all"/> <!--  this cleans up stuff not specifically supported by docx4all -->        
    2425                 
    2526<xsl:template match="@*|node()"> 
     
    2829  </xsl:copy> 
    2930</xsl:template> 
     31 
     32 
     33<xsl:template match="w:hyperlink"> 
     34         
     35        <!--  <w:hyperlink ns2:id="rId4" w:history="true"> 
     36                            <w:r> 
     37<w:rPr> 
     38    <w:rStyle w:val="Hyperlink"/> 
     39</w:rPr> 
     40<w:t>http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:12002E081:EN:NOT</w:t> 
     41                            </w:r> 
     42                        </w:hyperlink> 
     43                         --> 
     44         
     45        <xsl:choose> 
     46                <xsl:when test="$tidyForDocx4all=true()"> 
     47                        <xsl:apply-templates select="node()"/> 
     48                </xsl:when> 
     49                <xsl:otherwise> 
     50                  <xsl:copy> 
     51                        <xsl:apply-templates select="@*|node()"/> 
     52                  </xsl:copy> 
     53                </xsl:otherwise> 
     54        </xsl:choose> 
     55         
     56</xsl:template>  
     57 
     58<xsl:template match="w:lastRenderedPageBreak"> 
     59         
     60        <xsl:choose> 
     61                <xsl:when test="$tidyForDocx4all=true()"> 
     62                        <!-- ignore it --> 
     63                </xsl:when> 
     64                <xsl:otherwise> 
     65                  <xsl:copy> 
     66                        <xsl:apply-templates select="@*|node()"/> 
     67                  </xsl:copy> 
     68                </xsl:otherwise> 
     69        </xsl:choose> 
     70         
     71</xsl:template>  
     72 
     73<xsl:template match="w:tab"> 
     74         
     75        <xsl:choose> 
     76                <xsl:when test="$tidyForDocx4all=true()"> 
     77                          <!-- ignore it, since replacing with w:t 
     78                               or <w:t xml:space="preserve"> causes an exception. --> 
     79                </xsl:when> 
     80                <xsl:otherwise> 
     81                  <xsl:copy> 
     82                        <xsl:apply-templates select="@*|node()"/> 
     83                  </xsl:copy> 
     84                </xsl:otherwise> 
     85        </xsl:choose> 
     86         
     87</xsl:template>  
    3088 
    3189<xsl:template match="w:proofErr"> 
Note: See TracChangeset for help on using the changeset viewer.