public class XMLTagsParser extends Object
Constructor and Description |
---|
XMLTagsParser() |
Modifier and Type | Method and Description |
---|---|
static String |
escapeCharFromXML(String text)
Escapes characters for text appearing as XML data by HTML tags.
|
protected static String |
isAmpersandTag(String text,
int pos)
If the 'text' (from the position 'pos') is one of tags:
< > & " ' , – or —
then this tag is returned, else empty string will be returned.
|
protected static String |
isBRNewlineTag(String text,
int pos)
If the 'text' (from the position 'pos') is one of tags:
<br />,<br/>,<br> then this tag is returned,
else empty string will be returned.
|
static String |
replaceCharFromXML(String text,
char replacement)
Removes the following characters from the text:
<, >, &, ", also their expansions (<, >, &,
", ', , –, —)
by the 'replacement' character.
Replaces <br />,<br/>,<br> by newline symbol. Remains the character '. Attention: the parsing of other XML (HTML) tags should be done before this function execution, since open bracket '<' will be deleted. |
protected static String isAmpersandTag(String text, int pos)
pos
- position in 'text' from which the tag will be extractedprotected static String isBRNewlineTag(String text, int pos)
pos
- position in 'text' from which the tag will be extractedpublic static String replaceCharFromXML(String text, char replacement)
public static String escapeCharFromXML(String text)
The following characters are replaced with corresponding character entities :
Character | Encoding |
---|---|
< | < |
> | > |
& | & |
" | " |
' | ' |
Note that JSTL's <c:out>
escapes the exact same set of
characters as this method. That is, <c:out>
is good for escaping to produce valid XML, but not for producing safe HTML.
see: http://www.javapractices.com/topic/TopicAction.do?Id=96
Copyright © 2011-2016 Ubiquitous Knowledge Processing (UKP) Lab. All Rights Reserved.