Clover Coverage Report - XWiki Rendering - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 18:03:13 CET
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
5   61   3   1.67
0   22   0.6   3
3     1  
1    
 
  XHTMLWriter       Line # 32 5 0% 3 0 100% 1.0
 
  (239)
 
1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.rendering.internal.renderer.printer;
21   
22    import java.io.Writer;
23   
24    import org.dom4j.io.OutputFormat;
25    import org.dom4j.io.XMLWriter;
26   
27    /**
28    * XHTMLWriter is an helper to configure XMLWriter to format a DOM4J tree as XHTML.
29    *
30    * @version $Id: f4fd23fe9073e78d96d9caa3d7902b6561bf10bc $
31    */
 
32    public class XHTMLWriter extends XMLWriter
33    {
34    protected static final OutputFormat DEFAULT_XHTML_FORMAT;
35   
 
36  7 toggle static {
37  7 DEFAULT_XHTML_FORMAT = new OutputFormat();
38  7 DEFAULT_XHTML_FORMAT.setXHTML(true);
39    }
40   
 
41  247 toggle public XHTMLWriter(Writer writer)
42    {
43  247 super(writer, DEFAULT_XHTML_FORMAT);
44   
45    // escape all non US-ASCII to have as less encoding problems as possible
46  247 setMaximumAllowedCharacter(-1);
47    }
48   
49    /**
50    * Escapes a string to be used as an attribute value. Unlike the original method in {@link XMLWriter}, apostrophes
51    * are replaced by a numerical entity &, since ' is not valid in HTML documents.
52    *
53    * @param text the attribute value to escape
54    * @return the text with all occurrences of special XML characters replaced by entity references.
55    */
 
56  539 toggle @Override
57    protected String escapeAttributeEntities(String text)
58    {
59  539 return super.escapeAttributeEntities(text).replace("'", "&");
60    }
61    }