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 XML-escaped:
<transform xmlEscape>
<p>This paragraph has all XML special characters escaped.</p>
</transform>
...
- Version:
- $Id: XmlEscape.java,v 1.5 2002/03/09 20:57:05 revusky Exp $
- See Also:
HtmlEscape
Constructor Summary |
XmlEscape()
Creates new XmlEscape |
Method Summary |
boolean |
isEmpty()
|
void |
transform(java.io.Reader source,
java.io.Writer 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.Writer output)
throws TemplateModelException,
java.io.IOException
- 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.