freemarker.template.utility
Class XmlEscape
java.lang.Object
|
+--freemarker.template.utility.XmlEscape
- All Implemented Interfaces:
- TemplateModel, TemplateTransformModel
- public class XmlEscape
- extends java.lang.Object
- implements TemplateTransformModel
Performs an XML escape of a given template fragment. Specifically,
< > " ' and & are all turned into entities.
Usage:
From java:
TemplateModelRoot root = new SimpleHash();
root.put( "xmlEscape", new freemarker.template.utility.XmlEscape() );
...
From your FreeMarker template:
The following is executed:
<transform xmlEscape>
<p>This paragraph has all XML special characters escaped.</p>
</transform>
...
- Version:
- $Id: XmlEscape.java,v 1.2 2001/05/29 11:54:10 run2000 Exp $
- See Also:
HtmlEscape
|
Constructor Summary |
XmlEscape()
Creates new XmlEscape |
|
Method Summary |
boolean |
isEmpty()
|
void |
transform(java.io.Reader source,
java.io.PrintWriter output)
Transforms an XML-unescaped stream into XML-escaped form. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XmlEscape
public XmlEscape()
- Creates new XmlEscape
transform
public void transform(java.io.Reader source,
java.io.PrintWriter output)
throws TemplateModelException
- Transforms an XML-unescaped stream into XML-escaped form. This means:
< > & ' and " are all escaped into their equivalent entities.
- Specified by:
transform in interface TemplateTransformModel
- Parameters:
source - the input to be transformedoutput - the destination of the transformation
isEmpty
public boolean isEmpty()
throws TemplateModelException
- Specified by:
isEmpty in interface TemplateModel
- Returns:
- true if this object is empty.